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 foreign keys)All the keys must be enforced. Find base tables that implement M:N relationship types and that allow multiple relationships of the same type between the same entities.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
822Preventing strings that consist of only spaces instead of strings that consist of only whitespace charactersFind columns of base tables and foreign tables where one uses a check constraint to prevent values that consist of only spaces. Make sure that this is the correct constraint and there is no need to prevent values that consist of only whitespace characters.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
823Redundant indexesFind indexes that may be redundant. In addition to identical indexes it also considers indexes that cover the same columns and have the same properties except uniqueness. The query considers all types of indexes, including indexes that have been automatically created to support a constraint and function-based indexes.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
824Should the time zone be recorded in case of time or not?Find all the base table columns that have the type time without time zone or time with time zone. Return the data only if there is at least one column with the type time without time zone and one column with the type time with time zone.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
825Should the time zone be recorded in case of timestamp or not?Find all the base table columns that have the type timestamp without time zone or timestamp with time zone. Return the data only if there is at least one column with the type timestamp without time zone and one column with the type timestamp with time zone.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
826Some CHECKS are associated with a domain and some with the base table columns that have the domainFind cases where some CHECKS are associated with a domain and some with the base table columns that have the domain. Avoid duplication of code. Write as little code as possible. If possible, move things "before the brackets" so to say. In this case it means declaring CHECKS at the level of the domain and not at the level of base table columns.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
827Sorting rows based on random values in derived tablesFind derived tables (views and materialized views) that sort rows based on random values. This can be used to find a random subset of rows. It is a computationally expensive operation.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
828Table columns with NOT VALID CHECK constraintsFind CHECK constraints of base table and foreign table columns that are not valid. These constraints have been created so that the existing data has not been checked against the constraint. It could be deliberate in case of legacy systems that have data quality problems. However, ideally all the data in the table conforms to the constraint.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
829Tables without columnsDo not have in a database elements that are not useful. PostgreSQL permits tables with no columns. Such tables can be used to implement Boolean variables (tables TABLE_DEE and TABLE_DUM). On the other hand, such tables might be a result of database evolution, where developers have not noticed that they have dropped all the columns of a table or have not noticed that they have created such a table in the first place.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
830The expression of a check constraint that is associated with a domain needs type conversionFind check constraints of domains where the Boolean expression invokes an operation that does not match with the data type of the domain.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
831The expression of a simple check constraint that is associated directly with a column needs type conversionFind check constraints that involve one column and are associated directly with a table where the Boolean expression invokes an operation that does not match with the data type of the column.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
832The maximum number of characters may be missingPerhaps the character maximum length has been omitted accidentally, i.e., one wrote VARCHAR instead of VARCHAR(n) where n is the maximum permitted number of characters in the field value. VARCHAR and TEXT are synonyms.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
833Too short domain constraint namesFind names of domain constraints that are shorter than the length of the name of the domain + two characters.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
834Too 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
835Too short view namesNames should be expressive. Find views that name is shorter than the average length of the the names of its directly underlying tables (both base tables and derived tables).Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
836Unnecessary domainsDomain is a reusable artifact. Effort of its creation should be paid off by the advantages that it offers. If a domain is used in case of at most one column of a base table or even if it is used in case of more than one column but it does not specify neither a default value nor a check constraint, then there is no point of creating the domain.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
837Unused trigger functionsDo not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
838UPDATE triggers that maybe execute too oftenDo not let the system to do extra work. Ensure that trigger procedures are executed only if there is a real need of that. Find UPDATE triggers that could be executed too often because unneeded executions are not prevented.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
839Use invocation of a precise function instead of casting in a default value expressionBe precise and write as little code as possible. Prefer expressions with simple invocations of functions like localtimestamp, current_timestamp, and current_date over expressions like (now())::date. Find table columns that have a default value that casts the type of the returned value of a non-deterministic function (now, localtimestamp, current_timestamp, and current_date).Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
840Username is not uniqueFind textual columns that potentially contain usernames (including columns that potentially contain e-mail addresses) that do not have a unique constraint or a unique index that involves only this column.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License