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...
821Potentially missing PRIMARY KEY or UNIQUE constraints (based on UUIDs)If something has to be unique, then it must be said to the system so that it could use the information for internal optimizations and enforce the constraint. Find columns that contain Universally Unique Identifiers but are not a part of any simple PRIMARY KEY/UNIQUE constraint and are also not part of a foreign key.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-11-03 11:18MIT License
822Incorrect 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 tables2021-11-18 21:08MIT License
823Incorrect 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 tables2021-02-25 17:29MIT License
824Parameter name is the same as the name of a used columnIf the name of a routine parameter and the name of a column of a table that is used in the routine are the same, then it makes it more difficult to understand the code.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-01-20 13:54MIT License
825Parameter name is the same as the name of a used column (ver 2)If the name of a routine parameter and the name of a column of a table that is used in the routine are the same, then it makes it more difficult to understand the code.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-01-20 13:54MIT License
826Privileges to use base table columnsIf you do give privileges to base tables, then these should follow the principle of least privilege - the smallest possible amount of privileges to the smallest possible set of columnsGeneralINFORMATION_SCHEMA+system catalog base tables2020-12-29 10:38MIT License
827No point to have in a procedure COMMIT without ROLLBACK or vice versaIf you end transaction in a procedure, then there should be a possibility to either commit or rollback the transaction based on some condition. Procedures appeared in PostgreSQL 11.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 12:00MIT License
828CHECK constraints on columns with temporal dataIf your table contains columns with temporal data, then it will be appropriate to restrict the range of possible values in these columns because some of the values that belong to the type might not be appropriate (for instance, imagine a client who was born in 1100-12-03 or a contract that was registered in 3890-12-12- 12:45). If your table contains multiple columns with temporal data that denote events, then the rule about the order of the events must be enforced, if possible.GeneralINFORMATION_SCHEMA only2023-12-25 12:37MIT License
829FOR UPDATE is not allowed with aggregate functionsImplement explicit locking correctly. Instead of writing, for instance, SELECT Count(*) AS cnt FROM person WHERE person_id=1 FOR UPDATE; one has to write SELECT person_id FROM person WHERE person_id=1 FOR UPDATE;Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 11:23MIT License
830Names of database objects that contain two or more consecutive underscores or spaces as separators of name componentsImprove the readability of names. Find the names (identifiers) of user-defined database objects that contain two or more consecutive underscores or spaces that separate name components, i.e., these are not at the beginning and in the end of the name. Example of such names are person__id or "person id". Names with duplicate underscores use snake case style but duplication of underscores does not improve the usability of the name.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-03-18 16:48MIT License
831Names of database objects that start with an underscoreImprove the readability of names. Find the names (identifiers) of user-defined database objects that start with an underscore. This is not necessarily a mistake. For instance, parameter names could start with an underscore. On the other hand, it could be that the prefix is missing in the name.GeneralINFORMATION_SCHEMA+system catalog base tables2023-03-18 16:49MIT License
832The usage of double vs singular underscores or spaces in names as separator of name componentsImprove the readability of names. Find the number of names (identifiers) of user-defined database objects that contain two or more consecutive underscores or spaces as the separator of name components vs. the number of names that contain a single underscore or space to separate name components. Try to be consistent in the usage of underscores.Sofware measureINFORMATION_SCHEMA+system catalog base tables2023-03-17 11:11MIT License
833Inconsistent chain of relationships in terms of using ON UPDATE CASCADEIn 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 CASCADE should be consistent - either all the involved foreign keys have ON UPDATE CASCADE compensating action or none of these have it. 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 only2021-02-25 17:30MIT License
834JSON type instead of JSONB type"In general, most applications should prefer to store JSON data as jsonb, unless there are quite specialized needs, such as legacy assumptions about ordering of object keys." (https://www.postgresql.org/docs/current/datatype-json.html)Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
835Initially deferred constraint triggers with unnecessary lockingInitially deferred constraint triggers do not need explicit statements for locking tables or rows.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-08 11:25MIT License
836Routines with INSERT statements that are sensitive towards the order of columnsINSERT statements shouldn't be sensitive towards the order of columns. If one changes the order of columns in a table then these statements must be rewritten. Otherwise the code will not work or works incorrectly.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 16:15MIT License
837Primary key columns are not the first in a tableIn SQL tables each column has the ordinal position. Find all the base tables where the primary key columns are not the first in the table, i.e., there is at least one non-primary key column that comes before a primary key column. It is easier to grasp the primary key if its columns are the first in the table. It could be that a table inherits from an abstract table where no keys have been defined.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-16 10:33MIT License
838Routine body has keywords that are not in uppercaseKeywords in uppercase improve readability.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-12-24 17:06MIT License
839Extension routines that execution privilege has been granted to PUBLICKnow the privileges that users have in your system. Probably all the database users do not need these privileges.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
840AND takes precedence over ORMake sure that Boolean expressions take into account precedence rules of Boolean operators. AND operator has precedence over OR operator.GeneralINFORMATION_SCHEMA+system catalog base tables2020-11-06 14:51MIT License