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...
121Perhaps default value 'infinity' is missingFind optional base table columns that have a timestamp type and do not have a default value.Problem detectionINFORMATION_SCHEMA only2024-11-28 14:58MIT License
122The same CHECK has a different name in different places (2)Find the names of table CHECK constraints that have the same Boolean expression but a different naming style in different places (tables). The naming of constraints should be consistent. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)Problem detectionsystem catalog base tables only2024-11-28 14:47MIT License
123The same CHECK has a different name in different placesFind the names of table CHECK constraints that have the same Boolean expression but a different naming style in different places (tables). The naming of constraints should be consistent. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)xProblem detectionsystem catalog base tables only2024-11-28 14:44MIT License
124Perhaps 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 detectionINFORMATION_SCHEMA only2024-11-28 13:23MIT License
125Inconsistent chain of relationships in terms of using ON UPDATE compensating actionIn case of a chain of relationships between tables (where the primary key and the foreign key have the same columns) the use of ON UPDATE compensating action should be consistent. For instance, in the next example there is inconsistency, because if one changes the person_code in table Person, then the modification does not succeed because it does not cascade to the table Product. It is unclear as to whether it should be possible to change the person_code or not. Person (person_code, surname) Primary key (person_code) Worker(person_code)
Primary key (person_code)
Foreign key (person_code) References Person (person_code) ON UPDATE CASCADE

Product(product_code, registrator)
Primary key (product_code)
Foreign key (registrator) References Worker (person_code) ON UPDATE NO ACTION
Problem detectionsystem catalog base tables only2024-11-28 12:43MIT License
126Cascading update is not needed (based on surrogate keys)Find foreign key constraints that reference to a candidate key that is a surrogate key, i.e., its values are generated by the system by using sequence generators. Do not use ON UPDATE CASCADE, ON UPDATE SET NULL, and ON UPDATE SET DEFAULT in case of foreign keys that reference to surrogate keys.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-28 12:31MIT License
127Non-foreign key base table columns with the same name have a different set of CHECK constraintsFind non-foreign key base table columns that have the same name but a different set of check constraints. The use of constraints should be consistent and all the necessary constraints must be enforced. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-24 12:06MIT License
128Perhaps CHECK should be associated with a domainFind cases where multiple columns with the same domain have exactly the same CHECK constraint that is directly associated with the table.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-23 15:03MIT License
129Incorrect use of non-deterministic functions in CHECK constraintsDo not create a constraint in case of which data that satisfied a constraint c at the registration time suddenly does not satisfy it any more as the time goes by. Find all the check constraints that use non-deterministic functions (now, current_timestamp, localtimestamp, current_date, current_time) in a way that makes this situation possible. Fort instance, localtimestamp(0)>end_date is an example of such constraint.Problem detectionINFORMATION_SCHEMA only2024-11-22 15:29MIT License
130Duplicate domainsFind domains that have the same properties (base type, character length, not null + check constraints, default value, collation). There should not be multiple domains that have the same properties. Do remember that the same task can be solved in SQL usually in multiple different ways. Therefore, the domains may have syntactically different check constraints that solve the same task. Thus, the exact copies are not the only possible duplication.Problem detectionINFORMATION_SCHEMA only2024-11-21 15:14MIT License
131Sometimes current_timestamp, sometimes now()Find as to whether you sometimes use current_timestamp function and sometimes now() function. These implement the same functionality.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-21 13:20MIT License
132Sometimes extract, sometimes date_partFind as to whether you sometimes use date_part function and sometimes extract function. These implement the same functionality.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-21 13:18MIT License
133Sometimes regexp_like, sometimes ~Find as to whether you sometimes use regexp_like function and sometimes ~ operator. These implement the same functionality. regexp_like function that was added to PostgreSQL 15 and provides the same functionality as ~ and ~* operators. Try to be consistent.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-21 12:36MIT License
134Index FILLFACTOR is not defaultFind all indexes where FILLFACTOR is not default, i.e., it has been changed. The default is different in case of different index types is different. In case of B-tree indexes the default is 90.Generalsystem catalog base tables only2024-11-21 09:28MIT License
135FILLFACTOR is probably too bigFind base tables in case of which the FILLFACTOR property has perhaps a too big value. Try to find base tables that probably encounter UPDATE operations. In the tables that have frequent updates you want to have free space in table pages (blocks) to accommodate new row versions, which the system automatically creates as a result of fulfilling UPDATE statements. If a new row version will be put to another page by the system, then it means that table indexes have to be updated as well. Thus, the more there are indexes, the more the table would benefit from keeping a new row version in the same page as the old version.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-21 09:19MIT License
136Inconsistent referencing to character classes (shorthand vs long name) (2)Find as to whether different syntaxes (e.g., \w vs [[:alnum:]]) are used to refer to alphanumeric characters within the database.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-19 11:32MIT License
137Inconsistent referencing to character classes (shorthand vs long name)Find as to whether different syntaxes (e.g., \s vs [[:space:]]) are used to refer to character classes within the same database.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-11-19 11:24MIT License
138Storing a duration as timeFind columns of base and foreign tables that based on the column names are used to register durations but the type of the column is time. "It is possible to use a TIME data type if the duration is less than 24 hours, but this is not what the type is intended for, and can be the cause of confusion for the next person who has to maintain your code."Problem detectionINFORMATION_SCHEMA only2024-11-06 10:46MIT License
139Storing a duration rather than a point in timeFind columns of base and foreign tables that based on the column names and types are used to register start time and duration rather than start time and end time.Problem detectionINFORMATION_SCHEMA only2024-11-06 09:59MIT License
140Do not register age as a numberFind columns of base and foreign tables that based on the column name and type are used to register age.Problem detectionINFORMATION_SCHEMA only2024-11-06 09:55MIT License