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...
861Names of database objects that are used to manage the state of main objects in the database"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) The naming must be consistent. One should avoid mixing synonyms like "seisund", "staatus", and "olek" in Estonian or "state" and "status" in English and stick with one term.GeneralINFORMATION_SCHEMA+system catalog base tables2023-03-18 16:53MIT License
862Inconsistent names of database objects that are used to manage the state of main objects in the database"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) The naming must be consistent. One should avoid mixing synonyms like "seisund", "staatus", and "olek" in Estonian or "state" and "status" in English and stick with one term. For instance, it is a bad practice to use word "state" in table names but word "status" in function names.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-03-18 17:13MIT License
863Names of database objects with perhaps too many subcomponents (terms)"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) The number of subcomponents (terms) should not be too big. Find the names (identifiers) of user-defined database objects that perhaps contain too many subcomponents, assuming, that the separator of the components is "_".Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-03-17 10:02MIT License
864The number and percentage of different names of database objectsNames should be expressive. Find the number of different names used in a database as well as the number of named database objects, and the percentage of different names from all the names. Names should be expressive. Different objects should have different names. The smaller the percentage the less descriptive are the names in the database. Find the number of different names (identifiers) of user-defined database objects and compare it with the total number of database objects. The values could be used to compare different databases.Sofware measureINFORMATION_SCHEMA+system catalog base tables2023-03-18 17:12MIT License
865Too 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
866Inconsistency (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
867Perhaps too many different prefixes in the names of database objects that have the same typeOne should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-03-18 17:16MIT License
868Perhaps too many different suffixes in the names of database objects that have the same typeOne should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-03-17 11:14MIT License
869The 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
870Numeric literals between apostrophesPlacing numeric literals between apostrophes will cause unnecessary type conversions. It could also be that the literal should indeed be textual but the problem is in choosing the values. For instance, table Occupation has column occupation_code with the type VARCHAR(3). However, all the values in the column consist of digits (for instance, 1, 2, 3). Thus, it would have been better to a) use SMALLINT as the column type or b) use different occupation codes that contain additional symbols to digits.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 13:20MIT License
871Unnecessary usage privileges of PUBLICPostgreSQL gives by default some privileges to all the present and future database users (PUBLIC). Find usage privileges of collations, domains, foreign data wrappers, foreign servers, and sequences that have been given to PUBLIC.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-12-31 13:53MIT License
872Invalid character classPostgreSQL regular expressions do not have character classes word and letter.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 12:50MIT License
873Explicit lockingPostgreSQL uses Multi-version Concurrency Control (MVCC) and thus, sometimes, one has to explicitly lock certain rows or entire table. One has to use LOCK TABLE or SELECT … FOR UPDATE statements for that.GeneralINFORMATION_SCHEMA+system catalog base tables2023-12-11 15:02MIT License
874Explicit locking is missingPostgreSQL uses multiversion concurrency control (MVCC). SELECTs do not block modifications and vice versa. One has to take steps to achieve correct behaviour.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-01-14 00:35MIT License
875Foreign keys with ON UPDATE CASCADEReferential constraints (foreign key constraints) that employ ON UPDATE CASCADE compensatory action. ON UPDATE CASCADE should only be used if the referenced key is a natural key (its values can be changed).Generalsystem catalog base tables only2020-11-15 15:39MIT License
876Referential degree of a schemaReferential degree of a schema is defined as the number of foreign keys in the database schema.Sofware measureINFORMATION_SCHEMA only2020-11-13 11:30MIT License
877Case insensitive searchRefers to the column pg_proc.prokind and thus works starting from PostgreSQL 11. Find user-defined routines and derived tables (views/materialized views) that have a subquery with case insensitive search (by using the upper or lower function or ILIKE predicate or (?i) modifier of a regular expression pattern).GeneralINFORMATION_SCHEMA+system catalog base tables2021-10-25 16:55MIT License
878Overloading may cause runtime errorRoutines in the same schema that have the same name and that have parameters with different types or different number of parameters are not considered to be in conflict at the creation time. However, if defaults are provided in the definition of parameters, then these routines might be conflict during runtime.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-25 16:11MIT License
879Unsecure SECURITY DEFINER routinesSECURITY DEFINER routines must be secured against the malicious use of pg_temp schema. Find routines that do not explicitly set the search path or do it incorrectly (the search path is between quotation marks) and are thus potential targets of the attack. pg_temp must be the last entry in search_path. The lack of search_path is allowed only if the SQL statements in routines explicitly refer to the schemas that contain the schema objects.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-11-13 12:07MIT License
880SELECT * in a routine bodySELECT statement should list the columns not use SELECT * to return data from all the columns. Firstly, it ensures, that the query asks only data that is really needed by the routine. It means less data that the DBMS has to fetch and pass to the routine. It could also mean that the DBMS can answer to a query based on an index without reading table blocks. Secondly, it documents the data that is returned by the query. The query does not consider objects that are a part of an extension.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 15:03MIT License