Filter Queries

Found 1056 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 multiple surrogate keys

INFORMATION_SCHEMA+system catalog base tables

This query identifies base tables with a potentially redundant key structure. It specifically targets those having more than one PRIMARY KEY or UNIQUE constraint defined on a single integer-type column whose name matches the surrogate key naming convention (id_* or *_id). This pattern is a strong indicator of multiple surrogate keys for the same entity, which can indicate an overcomplicated data model. A single entity should typically have only one system-generated identifier to maintain schema clarity, simplify join logic, and avoid redundancy. The presence of multiple such keys warrants a review to determine if one is superfluous.

Problem detection License: MIT (opens in new tab)

#702. Perhaps primary key columns could be renamed

system catalog base tables only

Find the names of simple primary key columns that name does not follow the pattern _id or _code but it is quite similar.

Problem detection License: MIT (opens in new tab)

#703. Perhaps searching based on a name instead of a code

INFORMATION_SCHEMA+system catalog base tables

Find derived tables with a search condition that is possible based on a name instead of a code.

Problem detection License: MIT (opens in new tab)

#704. Perhaps spaces are unnecessarily restricted

INFORMATION_SCHEMA+system catalog base tables

Find base table columns that name refers to the possibility that the column is used to record names or textual descriptions but the column seems to have a simple check constraint that restricts spaces in these.

Problem detection License: MIT (opens in new tab)

#705. Perhaps the column type should be UUID

INFORMATION_SCHEMA only

Find base table columns that do not have uuid type but the name of the column refers to the possibility that the values in the column are uuid's.

Problem detection License: MIT (opens in new tab)

#706. Perhaps the name referes to multiple concepts

INFORMATION_SCHEMA+system catalog base tables

Find database objects that name contains words "and" (English) or "ja" (Estonian).

Problem detection License: MIT (opens in new tab)

#707. Perhaps the precision in case of a base table column with NUMERIC/DECIMAL type is too small

INFORMATION_SCHEMA only

Make sure that in case of using the type DECIMAL/NUMERIC as the type of a base table column the precision (the permitted number of digits in the number) is not too small. For instance, the biggest value in the type NUMERIC(1,1) is 0.9.

Problem detection License: MIT (opens in new tab)

#708. Perhaps the type of a base table column/domain should be BOOLEAN (based on CHECK constraints)

INFORMATION_SCHEMA+system catalog base tables

This query identifies base table columns and domains that utilize CHECK constraints to simulate boolean logic on non-boolean data types. It targets constraints that restrict the domain of permitted values to binary sets, such as {0, 1}, {'Y', 'N'}, {'T', 'F'}, or string literals like 'true'/'false'. While functional, this "pseudo-boolean" pattern is considered suboptimal in PostgreSQL. The native BOOLEAN data type is preferred for its storage efficiency, semantic clarity, and built-in support for logical operators, rendering such manual constraints unnecessary.

Problem detection License: MIT (opens in new tab)

#709. Perhaps the type of a base table column/domain should be BOOLEAN (based on types and default values)

INFORMATION_SCHEMA only

Find base table columns and domains that have a textual type and the default value that represents a truth-value. For instance, the type of a column could be VARCHAR and the column has the default value 'TRUE'.

Problem detection License: MIT (opens in new tab)

#710. Perhaps the type of a base table column/domain should be INTEGER/SMALLINT/BIGINT (based on sequence generators)

INFORMATION_SCHEMA only

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 refer to the nextval function by using the default value mechanism but do not have the type INTEGER, SMALLINT, or BIGINT. This check is performed in case of identity columns: ERROR: identity column type must be smallint, integer, or bigint.

Problem detection License: MIT (opens in new tab)

#711. Perhaps the type of a base table column/domain should be numeric (based on default values)

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#712. Perhaps the type of a base table column/domain should be SMALLINT (based on classifiers)

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#713. Perhaps the type of a base table column/domain should be temporal (based on default values)

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#714. Perhaps the type of a base table column/domain should be temporal (deadlines)

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#715. Perhaps the type of a base table column/domain should be VARCHAR (based on column names)

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#716. Perhaps the type of a base table column should be an integer type (based on column names)

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#717. Perhaps the type of a base table column should be BOOLEAN (based on column names)

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#718. Perhaps the type of a base table column should be BOOLEAN (based on enumerated types)

INFORMATION_SCHEMA+system catalog base tables

Find base table columns that have an enumerated type that seems to emulate Boolean type.

Problem detection License: MIT (opens in new tab)

#719. Perhaps the type of a base table column should be TIMESTAMPTZ

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#720. Perhaps the type of a base table column should be TSTZRANGE

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(activate to sort ascending) Type(sorted ascending, activate to sort descending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
701 Perhaps multiple surrogate keys This query identifies base tables with a potentially redundant key structure. It specifically targets those having more than one PRIMARY KEY or UNIQUE constraint defined on a single integer-type column whose name matches the surrogate key naming convention (id_* or *_id). This pattern is a strong indicator of multiple surrogate keys for the same entity, which can indicate an overcomplicated data model. A single entity should typically have only one system-generated identifier to maintain schema clarity, simplify join logic, and avoid redundancy. The presence of multiple such keys warrants a review to determine if one is superfluous. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
702 Perhaps primary key columns could be renamed Find the names of simple primary key columns that name does not follow the pattern _id or _code but it is quite similar. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
703 Perhaps searching based on a name instead of a code Find derived tables with a search condition that is possible based on a name instead of a code. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
704 Perhaps spaces are unnecessarily restricted Find base table columns that name refers to the possibility that the column is used to record names or textual descriptions but the column seems to have a simple check constraint that restricts spaces in these. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
705 Perhaps the column type should be UUID Find base table columns that do not have uuid type but the name of the column refers to the possibility that the values in the column are uuid's. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
706 Perhaps the name referes to multiple concepts Find database objects that name contains words "and" (English) or "ja" (Estonian). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
707 Perhaps the precision in case of a base table column with NUMERIC/DECIMAL type is too small Make sure that in case of using the type DECIMAL/NUMERIC as the type of a base table column the precision (the permitted number of digits in the number) is not too small. For instance, the biggest value in the type NUMERIC(1,1) is 0.9. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
708 Perhaps the type of a base table column/domain should be BOOLEAN (based on CHECK constraints) This query identifies base table columns and domains that utilize CHECK constraints to simulate boolean logic on non-boolean data types. It targets constraints that restrict the domain of permitted values to binary sets, such as {0, 1}, {'Y', 'N'}, {'T', 'F'}, or string literals like 'true'/'false'. While functional, this "pseudo-boolean" pattern is considered suboptimal in PostgreSQL. The native BOOLEAN data type is preferred for its storage efficiency, semantic clarity, and built-in support for logical operators, rendering such manual constraints unnecessary. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
709 Perhaps the type of a base table column/domain should be BOOLEAN (based on types and default values) Find base table columns and domains that have a textual type and the default value that represents a truth-value. For instance, the type of a column could be VARCHAR and the column has the default value 'TRUE'. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
710 Perhaps the type of a base table column/domain should be INTEGER/SMALLINT/BIGINT (based on sequence generators) 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 refer to the nextval function by using the default value mechanism but do not have the type INTEGER, SMALLINT, or BIGINT. This check is performed in case of identity columns: ERROR: identity column type must be smallint, integer, or bigint. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
711 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 (opens in new tab)
712 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 (opens in new tab)
713 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 (opens in new tab)
714 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 (opens in new tab)
715 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 (opens in new tab)
716 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 (opens in new tab)
717 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 (opens in new tab)
718 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 (opens in new tab)
719 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 (opens in new tab)
720 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 (opens in new tab)