Catalog of PostgreSQL queries for finding information about a PostgreSQL database and its design problems

ANDEach row in the result could represent a flaw in the design
AND
AND
ANDFrom where does the query gets its information?
AND
AND

There are 659 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
461Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2)Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-12-23 13:39MIT License
462Perhaps unnecessary privileges to use the databaseFind as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database.Problem detectionsystem catalog base tables only2021-11-23 20:42MIT License
463Perhaps updating of modification time is missingFind routines with SQL-standard body that seem to update data in a table that has a column for modification time but the routine does not seem to update the modification time while updating the row.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-11-24 12:59MIT License
464Perhaps USING syntax could be used for joining in the subqueries of derived tablesFind derived tables that use newer join syntax where join conditions are written in the WHERE clause but do not use USING synatx.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-11-10 14:14MIT License
465Permitting in a column only empty strings and strings that consist of whitespace charactersFind table CHECK constraints that permit in a column only empty strings or strings that consist of only whitespace characters.Problem detectionINFORMATION_SCHEMA only2021-12-19 15:10MIT License
466Personal names are uniqueFind all primary key and unique constraints of base tables that involve at least one column with personal names. Personal names are not unique and these cannot be (usually) used to guarantee uniqueness. Either one has declared a superkey instead of candidate key (i.e., the key contains a column that is not needed for uniqueness) or the key columns have been found incorrectly.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
467Phone number column has an incorrect data typeFind the columns where the name reffers to the possibility that the column contains phone numbers but the type of the column is not VARCHAR or TEXT.Problem detectionINFORMATION_SCHEMA only2021-03-27 19:00MIT License
468PL/pgSQL functions with consecutive RETURN clausesFind PL/pgSQL functions with consecutive RETURN clauses. Only the first RETURN will be used, others are unnecessary.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-12-16 11:38MIT License
469PL/pgSQL functions without the RETURN clauseThe return value of a function cannot be left undefined. If control reaches the end of the top-level block of the function without hitting a RETURN statement, a run-time error will occur. This restriction does not apply to functions with output parameters and functions returning void, however. In those cases a RETURN statement is automatically executed if the top-level block finishes. It also does not apply to trigger functions that only task is to raise an exception.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-10-29 11:13MIT License
470PL/pgSQL routine with plain SELECTFind PL/pgSQL that contain a SELECT statement that is not a SELECT … INTO statement. This is not permitted in PL/pgSQL routines.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-25 17:07MIT License
471Pointlessly returned valueThe value that is returned by a function should depend on something. If you do not have anything meaningful to return (for instance, the function always returns true, false, NULL, or the same number), then write VOID instead of the return type.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 15:01MIT License
472Potential duplication of sequence generatorsDo not create unnecessary sequence generators.Problem detectionINFORMATION_SCHEMA only2022-11-21 11:01MIT License
473Potentially a classifier table is missing (based on field sizes)Find columns that are not covered by a primary key, unique, and foreign key constraint but have a textual type with the maximum field size 3 or less and where the column name does not refer to names or comments. Return only data about these columns where there is no table with a similar name. Return data only about tables that could be referenced from more than one table.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-18 20:08MIT License
474Potentially missing default values of base table columnsFind columns of base tables without a default value that are either Boolean columns that based on the name seem to implement a state machine or temporal columns that based on the name seem to keep registration or update time. These columns often have a default value.Problem detectionINFORMATION_SCHEMA only2023-11-15 17:03MIT License
475Potentially missing PRIMARY KEY or UNIQUE constraints (based on column names)Find columns of base tables that name refers to the possibility that it contains unique values but the column does 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 tables2023-11-17 18:09MIT License
476Potentially 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
477Potentially 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
478Potentially 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
479Potentially missing sequence generators (based on column names and types)Find surrogate key columns that do not have an associated sequence generator. 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.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-08 00:44MIT License
480Potentially 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