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 996 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
1SQL routines that return the value of an input parameterFind SQL routines that return the value of an input parameter.Problem detectionINFORMATION_SCHEMA+system catalog base tables2025-01-20 14:23MIT License
2Check as to wheteher the names of columns are in the plural or in the singular form (Estonian version)Check as to wheteher the names of tables are in the plural or in the singular form. Make sure that you are consistent in naming.GeneralINFORMATION_SCHEMA+system catalog base tables2025-01-15 14:20MIT License
3Check as to wheteher the names of parameters are in the plural or in the singular form (Estonian version)Check as to wheteher the names of routine parameters are in the plural or in the singular form. Make sure that you are consistent in naming.GeneralINFORMATION_SCHEMA+system catalog base tables2025-01-15 14:19MIT License
4Inconsistent use of plural and singular in table names in the context of a relationship (Estonian version)Find foreign key constraints in case of which the name of one of the tables is in plural and the name of another table is in singular.Problem detectionINFORMATION_SCHEMA+system catalog base tables2025-01-15 14:18MIT License
5Duplicate removal of duplicates in derived tablesFind derived tables (views and materialized views) that contain both DISTINCT and GROUP BY. Make sure that the means for removing duplicate rows from the query result are not duplicated.Problem detectionINFORMATION_SCHEMA+system catalog base tables2025-01-15 14:16MIT License
6ROW level BEFORE DELETE and INSTEAD OF DELETE triggers that procedures refer to the row variable NEWDo not write incorrect code. Variable NEW: "Data type RECORD; variable holding the new database row for INSERT/UPDATE operations in row-level triggers. This variable is null in statement-level triggers and for DELETE operations." (PostgreSQL documentation)Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-28 11:31MIT License
7ROW level BEFORE INSERT and INSTEAD OF INSERT triggers that procedures refer to the row variable OLDDo not write incorrect code. Variable OLD: "Data type RECORD; variable holding the old database row for UPDATE/DELETE operations in row-level triggers. This variable is null in statement-level triggers and for INSERT operations." (PostgreSQL documentation)Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-28 11:27MIT License
8Incorrect prefix of a constraint name or an index nameIf the name of an object has the prefix that refers to the type of the object (for instance, primary key constraint or foreign key constraint), then you should use references to the correct object type. Find prefixes of constraint names and index names that incorrectly refer to the type of the object. For instance, incorrect would be to use chk_ as the prefix of an index name or pk_ as the prefix of a check constraint name.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-28 10:48MIT License
9Incorrect suffix of a constraint name or an index nameIf the name of an object has the suffix that refers to the type of the object (for instance, primary key constraint or foreign key constraint), then you should use references to the correct object type. Find suffixes of constraint names and index names that incorrectly refer to the type of the object. For instance, incorrect would be to use _chk as the suffix of an index name or _pk as the suffix of a check constraint name.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-28 10:44MIT License
10Base table columns permitting empty strings and strings that consist of only whitespace characters (2)Find non-foreign key columns of base tables that have a textual type and do not have a simple CHECK constraint (i.e., a constraint that involves only one column) that seems to prohibit empty strings and strings that consist of only whitespace as well as a simple CHECK constraint that specifies permitted symbols.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-27 19:02MIT License
11Perhaps unnecessay regular expressionFind occurrences of possibly pointless regular expressions - i.e., value contains zero or more symbols.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-27 18:37MIT License
12Perhaps a too long PL/pgSQL routineA large routine may have multiple tasks that should be split between multiple routines, each of which has a more focused task. Find the PL/pgSQL routines where the number of physical lines of code is bigger than 40.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-27 11:13MIT License
13Routines 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-12-27 11:12MIT License
14The usage of data type formatting functionsFind expressions that use a data type formatting function - to_char, to_number, to_date, to_timestamp.GeneralINFORMATION_SCHEMA+system catalog base tables2024-12-25 19:57MIT License
15Perhaps unnecessary TrimFind constraints where the use of Trim function is possibly unnecessary. CHECK constraint column!~'^[[:space:]]*$' already ensures that the values in the column cannot be empty strings or strings that consist of only whitespace. Trim(Column)!~'^[[:space:]]*$' - in this case the use of Trim function is unnecessary.Problem detectionINFORMATION_SCHEMA only2024-12-25 15:27MIT License
16NOT IN or <> ALL in derived tablesAvoid using NOT IN or <>ALL with a non-correlated subquery in PostgreSQL because the query performance will be very poor, especially in case of large data sizes.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-24 13:50MIT License
17NOT IN or <> ALL in routinesAvoid using NOT IN or <>ALL with a non-correlated subquery in PostgreSQL because the query performance will be very poor.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-24 13:50MIT License
18Duplicate check of empty stringsFind columns that have a check that prevents the empty string in the column but there is already another check on the column that enforces the constraint. If there is a constraint description!~'^[[:space:]]*$', then it covers the constraint description!='' and the latter becomes redundant.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-23 14:28MIT License
19Perhaps is not a snake case - date, time, or by is not preceded by an underscoreFind names that perhaps do not use the snake_case naming style because the name ends with the phrase "date", "time", "by" that is not preceded by an underscore. Prefer snake_case over PascalCase and camelCase in names.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-12-23 13:56MIT License
20IS DISTINCT FROM should be used instead of <> in WHEN clausesUse a right predicate in trigger condition in order to ensure that the trigger executes always when it has to but not more often. IS DISTINCT FROM treats NULL as if it was a known value, rather than unknown. It would be relevant if a column that is referenced in the action condition is optional, i.e., permits NULLs.Problem detectionINFORMATION_SCHEMA only2024-12-23 12:29MIT License