Catalog of PostgreSQL queries for finding information about a PostgreSQL database and its design problems

AND
AND
AND
ANDFrom where does the query gets its information?
AND
AND

There are 961 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
881A large number of triggersShow user-defined triggers if there are more than 9 different trigger routine bodies, i.e., different triggers on different tables that do the same thing count as one trigger.GeneralINFORMATION_SCHEMA+system catalog base tables2023-12-25 11:23MIT License
882Perhaps 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 detectionINFORMATION_SCHEMA only2023-12-30 10:59MIT License
883Perhaps 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 detectionINFORMATION_SCHEMA only2021-03-04 11:24MIT License
884Do not clone columns"Split a base table column into multiple columns based on the values in some other column. Each such newly created column has the name, a part of which is a data value from the original tables."(Bill Karwin) Find base tables that have more than one columns with the same type and field size and the difference between the columns are the year or month number at the end of the column name (two or four numbers, preceded by an underscore).Problem detectionINFORMATION_SCHEMA only2022-11-28 15:15MIT License
885CHECK constraints that perhaps incorrectly consider 'infinity' and '-infinity' special valuesSuch special values belong to the types DATE, TIMESTAMP, NUMERIC, REAL, and DOUBLE PRECISION. No value can be bigger than infinity or smaller than -infinity. If the check constraint cheks that a value must be bigger than -infinity or smaller than infinity, then it does not restrict (almost) anything.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-12-07 20:13MIT License
886ROW-level BEFORE and INSTEAD OF triggers with RETURN NULLSuch triggers effectively cancel data modification. It might be correct but could also be a mistake. "Row-level triggers fired BEFORE can return null to signal the trigger manager to skip the rest of the operation for this row (i.e., subsequent triggers are not fired, and the INSERT/UPDATE/DELETE does not occur for this row). " (PostgreSQL documentation) "INSTEAD OF triggers (which are always row-level triggers, and may only be used on views) can return null to signal that they did not perform any updates, and that the rest of the operation for this row should be skipped (i.e., subsequent triggers are not fired, and the row is not counted in the rows-affected status for the surrounding INSERT/UPDATE/DELETE). " (PostgreSQL documentation)Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
887Table columns that are associated with a sequence generatorSurrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there is no usage of sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys.GeneralINFORMATION_SCHEMA only2021-03-07 21:06MIT License
888Base table columns with the type VARCHAR(1)The choice of data types should reveal as much as possible about the nature of the data in the column. The type of these columns could be CHAR(1) and they should have a constraint that a value in the column cannot be an empty string.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
889Columns with exact/floating numeric types have textual default valuesThe default value of a column should belong to the type of the column. The system shouldn't conduct unnecessary type casts.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
890Too short table constraint namesThe names should be expressive. Find names of constraints, which are associated directly to a table, that are shorter than the length of the name of the table + two characters.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
891Names of triggers and rules that do contain the table nameThe names should contain table name in order to make the names better understandable.GeneralINFORMATION_SCHEMA+system catalog base tables2023-01-13 19:23MIT License
892Names of triggers and rules that do not contain the table nameThe names should contain table name in order to make the names better understandable.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-01-13 19:18MIT License
893Different prefixes of a candidate key column and a referencing foreign key columnThe naming must be consistent. Find foreign key constraints where the candidate key column and foreign key column names have different prefixes. Thus, for instance, one cannot use USING syntax for joining the tables.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
894Different suffixes of a candidate key column and a referencing foreign key columnThe naming must be consistent. Find foreign key constraints where the candidate key column and foreign key column names have different suffixes. Thus, for instance, one cannot use USING syntax for joining the tables.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
895Names of columns with the type BOOLEANThe naming of BOOLEAN columns must be consistent. For the better readability the names of such columns could have prefix "is_" (in English) or "on_" (in Estonian)GeneralINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:41MIT License
896Columns with BOOLEAN type that do not have a good nameThe phrase "is_" or "has_" or "can_" (in English) or "on_" (in Estonian) should be used in the name - preferably in the beginning. Worse: agreed, kinnitatud. Better: contract_is_agreed, leping_on_kinnitatud. Perhaps the best: is_contract_agreed or is_agreement, on_leping_kinnitatud, on_kinnitatud.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:56MIT License
897Cannot accommodate all the fractional seconds in case of table columnsThe precision of a timestamp type of a column must be able to accommodate all the fractional seconds of the default value of the column. Find table columns with the type timestamp without time zone(m) or timestamp with time zone(m) that have a default value LOCALTIMESTAMP(n) or CURRENT_TIMESTAMP(n) WHERE n>m.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
898Columns with BOOLEAN type that do have a good nameThe prefic of the name should be "is_" or "has_" or "can_" (in English) or "on_" (in Estonian). Worse: agreed, kinnitatud. Better: is_agreement, on_kinnitatud.GeneralINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:56MIT License
899Routines with BOOLEAN return type that do not have a good nameThe prefic of the name should be "is_" or "has_" or "can_" (in English) or "on_" (in Estonian). Worse: check_rights. Better: has_rights.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-01-13 20:41MIT License
900Insufficient number of user-defined non-trigger routinesThere must be at least n (four in this case) user-defined non-trigger routines in the database.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License