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...
621The generator of surrogate key values can output the same value more than onceFind surrogate keys where the generator can output the same value more than once. Key values must be unique, i.e., at some point the generator will prevent adding new rows to the table.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-08 00:40MIT License
622Domains that are associated with a sequence generatorDomains are reusable artifacts. By associating a domain with a sequence generator, one essentially starts to share sequence generators between tables. It may cause a potential performance bottleneck by having a shared resource. By having a shared sequence it is not possible to change properties of sequences of different tables independently, i.e., it increases coupling between tables.Problem detectionINFORMATION_SCHEMA only2021-03-07 21:08MIT License
623The same sequence generator is used in case of multiple columnsDo not cause a potential performance bottleneck by having a shared resource. By having a shared sequence it is not possible to change properties of sequences of different tables independently (for instance the owner column or step), i.e., it increases coupling between tables. By having a shared sequence it is impossible to specify the owner (table column) to the sequence generator.Problem detectionINFORMATION_SCHEMA only2021-03-07 21:07MIT License
624Potentially unnecessary use of sequence generatorsFind simple natural key columns that are associated with a sequence generator.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-07 21:06MIT License
625Table columns that are associated with a sequence generatorSurrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there is no usage of sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys.GeneralINFORMATION_SCHEMA only2021-03-07 21:06MIT License
626Perhaps a unneccessary surrogate keyFind base tables that have the primary key that is not a surrogate key and an alternate key that is a surrogate key. Perhaps the surrogate key column is not needed.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-07 20:59MIT License
627Surrogate key columnsFind surrogate keys. Surrogate key is a key that consist of one column, which has an integer type. The key has been declared by using PRIMARY KEY or UNIQUE constraint. The column is associated with a sequence generator (either external or internal, i.e., created by the system automatically because the column has been declared as an identity column). The column does not participate in any foreign key.GeneralINFORMATION_SCHEMA+system catalog base tables2021-03-07 20:59MIT License
628Base table columns with UUID typeEach column should have the most appropriate data type. If one does not want to have in a table the surrogate key that values are generated by using a sequence generator, then one may use instead a column with Universally Unique Identifiers as the key column.GeneralINFORMATION_SCHEMA only2021-03-07 20:57MIT License
629Privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign serversFind privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers that are not for the owner and not for the systemic user postgres. Make sure that there is the right amount of privileges for each and every relevant user.Generalsystem catalog base tables only2021-03-07 20:57MIT License
630Definition of a non-minimal superkey instead of a candidate key (based on sequence generators)Candidate key is a minimal superkey, meaning that it is not possible to remove columns from the candidate key without losing its uniqueness property. One should define primary key's and unique constraints based on candidate keys. Find primary keys and unique constraints where a proper subset of the key is a column with an associated sequence generator. Most certainly such subset contains unique values. Thus, this subset should be the key, not its superset.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-07 20:56MIT License
631Potentially unused sequence generatorsFind sequence generators that are not associated with any column through the default value mechanism. Please note, that it is also possible to refer to a sequence generator from a routine or from an application. If these are indeed not used, then these should be dropped, otherwise these are dead code.Problem detectionINFORMATION_SCHEMA only2021-03-07 20:56MIT License
632The number of sequence generators in different schemasIdentify the number of sequence generators in different schemas. Surrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there are no sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys at the database level. An alternative is to implement generation of unique values at the application level or at the database level by using triggers. However, such implementation would most probably lead to the performance penalty because adding new rows to the table must be serialized, i.e., it can be done in one session at a time.Sofware measureINFORMATION_SCHEMA only2021-03-07 20:55MIT License
633Potentially missing PRIMARY KEY or UNIQUE constraints (based on sequence generators)Find columns of base tables that contain automatically generated unique values but do not belong to any PRIMARY KEY/UNIQUE constraint. 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.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-07 20:53MIT License
634Do not use a generic attribute tableFind base tables that implement a highly generic database design (EAV design - Entiry-Attribute-Value design), according to which attribute values are recorded in a generic table that contains attribute-value pairs.Problem detectionINFORMATION_SCHEMA only2021-03-07 17:40MIT License
635Do not always depend on one's parent (INFORMATION_SCHEMA)Find where a hierarchical structure is implemented in a base table by having a foreign key that refers to a candidate key of the same table. This design is called adjacency list.GeneralINFORMATION_SCHEMA only2021-03-07 10:57MIT License
636The number of tables by schema, by type, and in totalFind the number of tables (base, foreign, and derived) in different schemas.Sofware measureINFORMATION_SCHEMA+system catalog base tables2021-03-07 10:57MIT License
637Do not use dual-purpose foreign keysFind cases where the same column of a base table T is used to record references to multiple base tables. In addition, one has to add additional column to T for holding metadata about the parent table, referenced by the current row.Problem detectionINFORMATION_SCHEMA only2021-03-07 10:56MIT License
638Small tablesFind tables that have one column or zero columns.GeneralINFORMATION_SCHEMA+system catalog base tables2021-03-07 10:52MIT License
639Pairs of non-key column name and type pairs that have in different base tables a different default valueFind non-key base table columns with the same name and type that have different default values. Be consistent. Columns with the same name and type shouldn't probably have different default values in case of different tables. "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 tables2021-03-05 21:01MIT License
640Pairs of non-key column name and type pairs that have in some base tables a default value and some cases notFind non-key base table columns with the same name and type that have in some cases a default value and some cases not. Be consistent. Columns with the same name and type should probably either always have a default value in case of different tables or never have a default value in case of different tables. "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 tables2021-03-05 21:01MIT License