Filter Queries
- All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
- Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets, it shouldn't be a problem in case of the relatively small amount of data in the system catalog of a database.
#621. Names of database objects with perhaps too many subcomponents (terms)
INFORMATION_SCHEMA+system catalog base tables"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 "_".
#622. Names of database objects with perhaps too many subcomponents (terms) that consist of only consonants
INFORMATION_SCHEMA+system catalog base tablesFind names of database objects where the number of subcomponents (terms) that consist of only consonants is bigger than the number of subcomponents that contain at least one vowel.
#623. Names of the columns of derived tables that have been given by the system
INFORMATION_SCHEMA+system catalog base tablesFind columns of derived tables that name has been given by the system. The creators of the table should specify the name themselves to avoid ugly names and nasty surprises.
#624. Names of triggers and rules that do not contain the table name
INFORMATION_SCHEMA+system catalog base tablesThe names should contain table name in order to make the names better understandable.
#625. Name starts or ends with spaces
INFORMATION_SCHEMA+system catalog base tablesFind the names of user-defined database objects (must be delimited identifiers) that start or end with spaces.
#626. No need to use to_date or to_timestamp function
INFORMATION_SCHEMA+system catalog base tablesFind expressions where a date literal with the ISO format is converted to date/timestamp by using to_date or to_timestamp function.
#627. Non-foreign key columns that have no associated CHECK constraints
INFORMATION_SCHEMA onlyFind what are the base table columns that are not foreign key columns and that have no associated CHECK constraints? Perhaps some CHECK constraints are missing.
#628. Non-foreign key indexes that have been named as foreign key indexes
INFORMATION_SCHEMA+system catalog base tablesFind indexes that are not on a foreign key column but the name of the index contains ixfk or idxfk.
#629. Non-key and non-foreign key base table columns with the same name and type that have in some cases permit NULLs and in some cases not
INFORMATION_SCHEMA+system catalog base tablesFind non-key and non-foreign key base table columns with the same name and type that in some cases permit NULLs and in some cases not. Be consistent. Make sure that this selection is consistent.
#630. Non-native data types for network addresses
INFORMATION_SCHEMA onlyThis query identifies base table columns intended to store IP or network addresses that are not using PostgreSQL's native inet data type. It locates these columns by searching for specific English and Estonian naming patterns (such as 'ip', 'network', 'addr', or 'aadr'). Storing network addresses as generic text is an anti-pattern, as the inet type provides built-in validation, specialized network functions, and efficient indexing.
#631. Non-predefined character classes must not be between double square brackets
INFORMATION_SCHEMA+system catalog base tablesWrite correct regular expressions. For instance, if there is a rule that code must consist of one or more digits, then correct expression is code~'^[0-9]+$', not code~'^[[0-9]]+$'.
#632. Non-updatable views that have data modification privileges
INFORMATION_SCHEMA+system catalog base tablesBe precise and do not give impossible privileges.
#633. No-operation routines with static return values
INFORMATION_SCHEMA+system catalog base tablesThis query identifies SQL routines that are functionally equivalent to a no-operation (no-op) instruction, meaning their sole operation is to return either a constant literal or an unmodified input parameter. Such routines provide no transformation or logic. They are typically superfluous and may represent placeholder code from early development, refactoring artifacts where original logic was deprecated, or simple logical oversights. Eliminating these functions reduces code clutter, simplifies application logic, and removes a marginal but unnecessary layer of computational overhead.
#634. No point to have in a procedure COMMIT without ROLLBACK or vice versa
INFORMATION_SCHEMA+system catalog base tablesIf you end transaction in a procedure, then there should be a possibility to either commit or rollback the transaction based on some condition. Procedures appeared in PostgreSQL 11.
#635. Not enforced constraints
system catalog base tables onlyThis query identifies constraints (CHECK and FOREIGN KEY) that exist in the system catalog but are not actively enforced against the table data.
#636. Not equals check in unstandardized way
INFORMATION_SCHEMA+system catalog base tablesFind user-defined routines that use != operator to test as to whether two values are not equal.
#637. Not inherited CHECK constraints that are recreated in the immediate subtable
system catalog base tables onlyFind base table CHECK constraints that have been defined as NOT INHERITED but the constraint with the same Boolean expression has been defined in the immediate subtable of the table.
#638. Not inherited CHECK constraints that cover at least one column
system catalog base tables onlyFind CHECK constraints that cover at least one column and that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable.
#639. NOT IN or <> ALL in derived tables
INFORMATION_SCHEMA+system catalog base tablesAvoid using NOT IN or <>ALL with a non-correlated subquery in PostgreSQL because the query performance will be very poor, especially in case of large data sizes.
#640. NOT IN or <> ALL in routines
INFORMATION_SCHEMA+system catalog base tablesAvoid using NOT IN or <>ALL with a non-correlated subquery in PostgreSQL because the query performance will be very poor.
| # | Name(activate to sort ascending) | Goal(activate to sort ascending) | Type(sorted ascending, activate to sort descending) | Data source(activate to sort ascending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 621 | Names 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 detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 622 | Names of database objects with perhaps too many subcomponents (terms) that consist of only consonants | Find names of database objects where the number of subcomponents (terms) that consist of only consonants is bigger than the number of subcomponents that contain at least one vowel. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 623 | Names of the columns of derived tables that have been given by the system | Find columns of derived tables that name has been given by the system. The creators of the table should specify the name themselves to avoid ugly names and nasty surprises. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 624 | Names of triggers and rules that do not contain the table name | The names should contain table name in order to make the names better understandable. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 625 | Name starts or ends with spaces | Find the names of user-defined database objects (must be delimited identifiers) that start or end with spaces. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 626 | No need to use to_date or to_timestamp function | Find expressions where a date literal with the ISO format is converted to date/timestamp by using to_date or to_timestamp function. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 627 | Non-foreign key columns that have no associated CHECK constraints | Find what are the base table columns that are not foreign key columns and that have no associated CHECK constraints? Perhaps some CHECK constraints are missing. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 628 | Non-foreign key indexes that have been named as foreign key indexes | Find indexes that are not on a foreign key column but the name of the index contains ixfk or idxfk. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 629 | Non-key and non-foreign key base table columns with the same name and type that have in some cases permit NULLs and in some cases not | Find non-key and non-foreign key base table columns with the same name and type that in some cases permit NULLs and in some cases not. Be consistent. Make sure that this selection is consistent. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 630 | Non-native data types for network addresses | This query identifies base table columns intended to store IP or network addresses that are not using PostgreSQL's native inet data type. It locates these columns by searching for specific English and Estonian naming patterns (such as 'ip', 'network', 'addr', or 'aadr'). Storing network addresses as generic text is an anti-pattern, as the inet type provides built-in validation, specialized network functions, and efficient indexing. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 631 | Non-predefined character classes must not be between double square brackets | Write correct regular expressions. For instance, if there is a rule that code must consist of one or more digits, then correct expression is code~'^[0-9]+$', not code~'^[[0-9]]+$'. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 632 | Non-updatable views that have data modification privileges | Be precise and do not give impossible privileges. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 633 | No-operation routines with static return values | This query identifies SQL routines that are functionally equivalent to a no-operation (no-op) instruction, meaning their sole operation is to return either a constant literal or an unmodified input parameter. Such routines provide no transformation or logic. They are typically superfluous and may represent placeholder code from early development, refactoring artifacts where original logic was deprecated, or simple logical oversights. Eliminating these functions reduces code clutter, simplifies application logic, and removes a marginal but unnecessary layer of computational overhead. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 634 | No point to have in a procedure COMMIT without ROLLBACK or vice versa | If you end transaction in a procedure, then there should be a possibility to either commit or rollback the transaction based on some condition. Procedures appeared in PostgreSQL 11. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 635 | Not enforced constraints | This query identifies constraints (CHECK and FOREIGN KEY) that exist in the system catalog but are not actively enforced against the table data. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 636 | Not equals check in unstandardized way | Find user-defined routines that use != operator to test as to whether two values are not equal. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 637 | Not inherited CHECK constraints that are recreated in the immediate subtable | Find base table CHECK constraints that have been defined as NOT INHERITED but the constraint with the same Boolean expression has been defined in the immediate subtable of the table. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 638 | Not inherited CHECK constraints that cover at least one column | Find CHECK constraints that cover at least one column and that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 639 | NOT IN or <> ALL in derived tables | Avoid using NOT IN or <>ALL with a non-correlated subquery in PostgreSQL because the query performance will be very poor, especially in case of large data sizes. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 640 | NOT IN or <> ALL in routines | Avoid using NOT IN or <>ALL with a non-correlated subquery in PostgreSQL because the query performance will be very poor. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View |