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...
681Enumerated types with zero or one valueFidn enumerated types with zero or one value. Type is a named finite set of values. The empty set is a set. A set with one value is a set. Thus, types with zero or one value are legal. In practical terms each type, usually, should contain at least two values.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
682Exclude constraint instead of simple UNIQUEFind exclude constraints that implement a simple UNIQUE constraint. The checking might be slower compared to UNIQUE constraint.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
683Extension 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
684Foreign key column has a default value that is not present in the parent tableFind foreign key columns that have a default value that is not present in the parent table. Identify default values that cause violations of the referential constraints.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
685Foreign key columns that have no indexFind foreign key columns that do not have an index. Foreign key columns are often used for performing join operations. It is useful to index such columns.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
686Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraintFind foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
687Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraint while the referenced table has the primary keyFind foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns while at the same time the referenced table does have the primary key. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
688Foreign key refers to a table that has at least one subtable in the inheritance hierarchyFind foreign key constraints that refer to a base table that has at least one subtable in the inheritance hierarchy. Rows of the subtable do not belong to the supertable in terms of checking the referential integrity. Let us assume that there is a table T with a subtable Tsub. Let us also assume that table B has a foreign key that refers to the table T. If a row is inserted into Tsub, then this row cannot be referenced from B.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
689Function Upper or Lower is used in an index on a non-textual columnFind function-based indexes that are based on function Upper or Lower but have been defined on a non-textual column. Such indexes support case insensitive search but in case of non-textual columns this does not have a meaning.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
690Generated stored base table columns duplicates another column in the tableFind generated stored columns in PostgreSQL base tables that duplicate other columns in the table.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
691Gratuitous context in the names of parametersFind routine parameter names that contain the routine name. Names of routine parameters shouldn't contain the name of the routine. It makes the names too long. A routine cannot have two parameters with the same name.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
692Gratuitous context in the names of schema objectsFind schema objects that name starts with the schema name and then has at least one more symbol. "Shorter names are generally better than longer ones, so long as they are clear. Add no more context to a name than is necessary" (Robert C. Martin, Clean Code) Shema is a namespace. There cannot be in the same schema two schema objects that belong to the same name class and have the same name.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
693Identical indexesFind indexes that are identical, i.e., have the same properties, including 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:30MIT License
694Inconsistency (code vs. id) of naming foreign key and referenced candidate key columnsNaming of foreign key and referenced candidate key columns should be consistent. It cannot be so that in one table a value is labeled "id" like some surrogate key value and in another it "turns" into human-usable "code" or vice versa. An example:

Person(person_id, name)
Primary Key (person_id)

E_mail_address(e_mail_address_id, person_code, address)
Primary Key (e_mail_address_id)
Foreign key (person_code) References Person (person_id)
Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
695Inconsistent 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
696Inconsistent data type usage in case of registering a symbolFind whether the database uses both CHAR(1) and VARCHAR(1) columns to register a single symbol.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
697Input parameters that names do not follow the convention to start with _ or p_For the sake of making code better understandable follow naming conventions.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
698Insufficient number of user-defined base tablesThere must be at least n (seven in this case) user-defined base tables in the database.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
699Insufficient number of user-defined domainsThere must be at least n (one in this case) user-defined domains in the database each of that must be used in case of at least two columns of base tables.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
700Insufficient number of user-defined foreign tablesThere must be at least n (two in this case) user-defined foreign tables in the database.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License