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...
481Incorrect characterization of a user-defined routine as an "immutable" routineFind immutable routines that contain SELECT statements from a database (including SELECT .. FOR UPDATE), INSERT, UPDATE, DELETE, or LOCK statement. The DBMS should get a correct background information about the behaviour of a routine. Immutable routines should not have side effects and should also not ask data from a database because it could change over time. Immutable routines cannot lock tables or its specific rows.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 14:08MIT License
482Incorrect characterization of a user-defined routine as a "stable" routineFind stable routines that contain INSERT, UPDATE, DELETE, SELECT … FOR UPDATE, or LOCK statement. The DBMS should get a correct background information about the behaviour of a routine. Stable routines cannot modify data in a database, lock tables, or its specific rows.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 13:59MIT License
483Using routine name in front of a parameter name in a routine body to refer to the parameter of the routineWrite code that is easy to understand and not unnecessarily long. A routine cannot have two or more parameters with the same name. In this case using longer identifier in the form routine_name.parameter name is unnecessary.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 13:40MIT License
484User-defined routines that use positional references to parametersUse parameter names instead of positional references to improve code evolvability.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 13:18MIT License
485Unused named input parametersFind named input parameters that are not referenced in the routine body. All the parameters that are presented in the routine signature declaration must be used in its body. Otherwise these are dead code elements.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 13:03MIT License
486Middle-manFind a routine that's only task is to invoke another routine. If a routine performs only one action, delegating work to another routine, why does it exist at all?Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 12:48MIT License
487Routines without an actionFind routines that body does not contain any action.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 12:14MIT License
488Perhaps a routine does not have a real taskFind the routines where the only action is to return an argument value, a constant value, NULL or return the value of OLD or NEW variable in case of trigger functions.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 12:09MIT License
489Duplicate user-defined routinesFind user-defined routines with the exact duplicate body and parameters. There should not be multiple routines with exactly the same body and parameters (name, type). Having such duplicates is redundancy. Do remember that the same task can usually be solved in multiple different ways. Thus, the exact copies of routine bodies are not the only possible duplication. Moreover, it could be that different routines that solve the same task have different parameter names (but the parameters have the same types, ordinal positions, default values or the routines have different order of parameters). Thus, the query does not find all the duplications.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-05 11:59MIT License
490The total number of physical lines of code in the bodies of user-defined SQL and PL/pgSQL functions/proceduresFind a numerical measure that describes the extent of the database public interface (virtual data layer) through which users access the database.Sofware measureINFORMATION_SCHEMA+system catalog base tables2021-11-04 21:02MIT License
491Routine body only in uppercaseUppercase means screaming and having code entirely in uppercase makes its reading more difficult. On the other hand, it would be a good idea to have keywords in uppercase. Find routines that body contains a SQL data manipulation statement (which shouldn't be entirely in uppercase) but still the body is completely in uppercase.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 20:12MIT License
492Do not refer to the table schema in the references to columnsFind routines where in SELECT or UPDATE statements references to columns are prefixed with references to the table schema. Referring to schema in this context bloats the code.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 17:32MIT License
493Function in a function-based index of a column is different of the function that is used in the query in a routine based on the columnCreate appropriate indexes to speed up queries. If you apply a function to a column in a query, then create a function-based index based on the function to the column.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 17:26MIT License
494There is no reason to use PL/pgSQL if you do not use one or more features of a procedural languageUsing PL/pgSQL may cause context switching between declarative SQL and procedural PL/pgSQL. Thus use PL/pgSQL only if you truly need some of its constructs (variables, conditional statements, cycles, cursors, exception handling).Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 16:32MIT License
495Perhaps a regular expression could be simplifiedFind regular expressions that name character classes a-zA-Z.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 16:19MIT License
496Routines with INSERT statements that are sensitive towards the order of columnsINSERT statements shouldn't be sensitive towards the order of columns. If one changes the order of columns in a table then these statements must be rewritten. Otherwise the code will not work or works incorrectly.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 16:15MIT License
497Invalid use of the case insensitive search modifier in regular expressionsFind regular expression patterns that use (?i) modifier in any other place than at the beginning of the pattern or (?-i) in any place of the pattern. Such use of the modifiers is not supported by PostgreSQL.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 16:06MIT License
498SELECT * 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
499Pointlessly 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
500Names of character classes are not in the lowercaseFind regular expressions where the names of character classes are not completely in lowercase. For instance, incorrect is to write [[:UPPER:]] or [[:Upper:]] and correct is [[:upper:]].Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 13:22MIT License