Filter Queries
- All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
- Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets, it shouldn't be a problem in case of the relatively small amount of data in the system catalog of a database.
#701. Perhaps the type of a base table column/domain should be numeric (based on default values)
INFORMATION_SCHEMA onlySpecify for each column/domain a right data type that takes into account expected values in the column/domain. Find base table columns and domains that have a textual type but the default value that represents a number (for instance, '100', '2', or '0.22'). Exclude columns about formats.
#702. Perhaps the type of a base table column/domain should be SMALLINT (based on classifiers)
INFORMATION_SCHEMA onlyFind columns that name points to the possibility that values in this are classifier codes. The column has a numeric type but it is not SMALLINT. Usually each classifier type has so few values that type SMALLINT would be appropriate.
#703. Perhaps the type of a base table column/domain should be temporal (based on default values)
INFORMATION_SCHEMA onlyFind base table columns and domains that have a textual type but the default value that represents a temporal value (either a static value or invocation of a function that returns such value). Specify for each column/domain a right data type that takes into account expected values in the column/domain.
#704. Perhaps the type of a base table column/domain should be temporal (deadlines)
INFORMATION_SCHEMA onlyFind base table columns that name refers to the possibility that there are registered deadlines but the column does not have a temporal type.
#705. Perhaps the type of a base table column/domain should be VARCHAR (based on column names)
INFORMATION_SCHEMA onlyFind base table columns that have CHAR type, where character maximum length is bigger than 1 and the name of the column does not refer to the possibility that the column holds some kind of codes or flags or hash values.
#706. Perhaps the type of a base table column should be an integer type (based on column names)
INFORMATION_SCHEMA onlyFind columns of base tables where the name of the column has prefix or suffix "id" or has the name "id" but the column does not have an integer type or uuid type. A convention is to use the phrase "id" in the names of surrogate key columns.
#707. Perhaps the type of a base table column should be BOOLEAN (based on column names)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies a semantic mismatch between a column's name and its data type. It flags base table columns that adhere to a predicate-based naming convention (i.e., starting with is_, has_, can_, or on_) but are not defined with the BOOLEAN data type. This is a design flaw as it forces developers to infer and manage truthiness through other types (e.g., INTEGER, CHAR(1)), which undermines schema clarity, requires data type coercion in queries, and can compromise data integrity by permitting non-boolean states.
#708. Perhaps the type of a base table column should be BOOLEAN (based on enumerated types)
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that have an enumerated type that seems to emulate Boolean type.
#709. Perhaps the type of a base table column should be TIMESTAMPTZ
INFORMATION_SCHEMA onlyThis query identifies all base table columns defined with the timestamp without time zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones.
#710. Perhaps the type of a base table column should be TSTZRANGE
INFORMATION_SCHEMA onlyThis query identifies all base table columns defined with the range of timestamp without zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones.
#711. Perhaps the type of a base table column should be XML, JSON, or JSONB (based on column names)
INFORMATION_SCHEMA onlyFind base table columns that name refers to the possibility that these are used to register XML/JSON values. Find the columns that do not have an appropriate data type (xml, json, jsonb). One shouldn't use columns with a textual type to register such data.
#712. Perhaps the type of a parameter should be BOOLEAN (based on parameter names)
INFORMATION_SCHEMA+system catalog base tablesFind routine parameters that based on the name seem to hold truth values. Find parameters that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type.
#713. Perhaps too many different prefixes in the names of database objects that have the same type
INFORMATION_SCHEMA+system catalog base tablesOne should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names.
#714. Perhaps too many different suffixes in the names of database objects that have the same type
INFORMATION_SCHEMA+system catalog base tablesOne should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names.
#715. Perhaps too many input parameters
INFORMATION_SCHEMA+system catalog base tablesToo many parameters (in this case four or more) could be a sign of not separating concerns and having a routine that has more than one task.
#716. Perhaps too many square brackets
INFORMATION_SCHEMA+system catalog base tablesCharacter classes are surrounded by two pairs of square brackets.
#717. Perhaps too many subconditions in a CHECK constraint
INFORMATION_SCHEMA onlyFind check constraints of base table and foreign table columns that are either associated with more than one column and have at least one AND operation or are associated with exactly one column and have two or more AND operations.
#718. Perhaps unnecessary DECLARE section in a PL/pgSQL routine
INFORMATION_SCHEMA+system catalog base tablesFind PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the only task seems to be raising an exception. The query excludes the cases where the error message is constructed dynamically, i.e., in this case using a variable maybe justifiable.
#719. Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2)
INFORMATION_SCHEMA+system catalog base tablesFind PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty.
#720. Perhaps unnecessary privileges to use the database
system catalog base tables onlyFind as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database.
| # | Name(sorted ascending, activate to sort descending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(activate to sort ascending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 701 | Perhaps the type of a base table column/domain should be numeric (based on default values) | Specify for each column/domain a right data type that takes into account expected values in the column/domain. Find base table columns and domains that have a textual type but the default value that represents a number (for instance, '100', '2', or '0.22'). Exclude columns about formats. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 702 | Perhaps the type of a base table column/domain should be SMALLINT (based on classifiers) | Find columns that name points to the possibility that values in this are classifier codes. The column has a numeric type but it is not SMALLINT. Usually each classifier type has so few values that type SMALLINT would be appropriate. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 703 | Perhaps the type of a base table column/domain should be temporal (based on default values) | Find base table columns and domains that have a textual type but the default value that represents a temporal value (either a static value or invocation of a function that returns such value). Specify for each column/domain a right data type that takes into account expected values in the column/domain. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 704 | Perhaps the type of a base table column/domain should be temporal (deadlines) | Find base table columns that name refers to the possibility that there are registered deadlines but the column does not have a temporal type. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 705 | Perhaps the type of a base table column/domain should be VARCHAR (based on column names) | Find base table columns that have CHAR type, where character maximum length is bigger than 1 and the name of the column does not refer to the possibility that the column holds some kind of codes or flags or hash values. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 706 | Perhaps the type of a base table column should be an integer type (based on column names) | Find columns of base tables where the name of the column has prefix or suffix "id" or has the name "id" but the column does not have an integer type or uuid type. A convention is to use the phrase "id" in the names of surrogate key columns. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 707 | Perhaps the type of a base table column should be BOOLEAN (based on column names) | This query identifies a semantic mismatch between a column's name and its data type. It flags base table columns that adhere to a predicate-based naming convention (i.e., starting with is_, has_, can_, or on_) but are not defined with the BOOLEAN data type. This is a design flaw as it forces developers to infer and manage truthiness through other types (e.g., INTEGER, CHAR(1)), which undermines schema clarity, requires data type coercion in queries, and can compromise data integrity by permitting non-boolean states. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 708 | Perhaps the type of a base table column should be BOOLEAN (based on enumerated types) | Find base table columns that have an enumerated type that seems to emulate Boolean type. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 709 | Perhaps the type of a base table column should be TIMESTAMPTZ | This query identifies all base table columns defined with the timestamp without time zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 710 | Perhaps the type of a base table column should be TSTZRANGE | This query identifies all base table columns defined with the range of timestamp without zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 711 | Perhaps the type of a base table column should be XML, JSON, or JSONB (based on column names) | Find base table columns that name refers to the possibility that these are used to register XML/JSON values. Find the columns that do not have an appropriate data type (xml, json, jsonb). One shouldn't use columns with a textual type to register such data. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 712 | Perhaps the type of a parameter should be BOOLEAN (based on parameter names) | Find routine parameters that based on the name seem to hold truth values. Find parameters that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 713 | Perhaps too many different prefixes in the names of database objects that have the same type | One should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 714 | Perhaps too many different suffixes in the names of database objects that have the same type | One should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 715 | Perhaps too many input parameters | Too many parameters (in this case four or more) could be a sign of not separating concerns and having a routine that has more than one task. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 716 | Perhaps too many square brackets | Character classes are surrounded by two pairs of square brackets. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 717 | Perhaps too many subconditions in a CHECK constraint | Find check constraints of base table and foreign table columns that are either associated with more than one column and have at least one AND operation or are associated with exactly one column and have two or more AND operations. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 718 | Perhaps unnecessary DECLARE section in a PL/pgSQL routine | Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the only task seems to be raising an exception. The query excludes the cases where the error message is constructed dynamically, i.e., in this case using a variable maybe justifiable. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 719 | Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2) | Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 720 | Perhaps unnecessary privileges to use the database | Find as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View |