| 441 |
Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraint while the referenced table has the primary key |
Find foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns while at the same time the referenced table does have the primary key. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency. |
Problem detection |
system catalog base tables only |
2025-11-07 10:11 |
MIT License |
View |
| 442 |
Foreign key references a non-key (has optional columns) |
Find foreign key constraints that referenced column is optional. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 443 |
Foreign key references to a unique index columns not a unique key columns |
Find foreign key constraints that reference to the columns that are covered by a unique index not a unique key. |
Problem detection |
system catalog base tables only |
2025-11-07 10:11 |
MIT License |
View |
| 444 |
Foreign key refers to a table that has at least one subtable in the inheritance hierarchy |
Find foreign key constraints that refer to a base table that has at least one subtable in the inheritance hierarchy. Rows of the subtable do not belong to the supertable in terms of checking the referential integrity. Let us assume that there is a table T with a subtable Tsub. Let us also assume that table B has a foreign key that refers to the table T. If a row is inserted into Tsub, then this row cannot be referenced from B. |
Problem detection |
system catalog base tables only |
2025-11-07 10:11 |
MIT License |
View |
| 445 |
Foreign servers without user mappings |
Find foreign servers that do not have any associated user mappings. "A user mapping typically encapsulates connection information that a foreign-data wrapper uses together with the information encapsulated by a foreign server to access an external data resource." |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 446 |
Full text search columns that have no gin or gist index |
Find columns of base tabels and materialized views with the type tsvector that do not have a gin or a gist index. These are the preferred index types for text search. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 447 |
Full text search columns with other type of index than gin or gist index |
Find columns of base tabels and materialized views with the type tsvector that do not have a gin or a gist index but have another type of index (e.g., b-tree). Gin and Gist are the preferred index types for text search. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 448 |
Function in a function-based index of a column is different from the function that is used in the subquery of a derived table |
Find cases where the function of a function-based index of a column is different from the function that is used in the query in a derived table based on the column. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 449 |
Function 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 column |
Create 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 detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 450 |
Functions that have transactional control |
This query identifies user-defined functions that contain restricted Transaction Control Language (TCL) statements, such as BEGIN, COMMIT, ROLLBACK, or SAVEPOINT. In PostgreSQL, functions execute within the context of the calling query's transaction and are strictly prohibited from managing transaction boundaries. Attempting to execute these commands within a function body results in a runtime error. To implement transactional logic (such as committing data in batches), the code must be refactored into a PROCEDURE, which supports transaction management. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-12-14 12:25 |
MIT License |
View |
| 451 |
Function Upper or Lower is used in an index on a non-textual column |
Find function-based indexes that are based on function Upper or Lower but have been defined on a non-textual column. Such indexes support case insensitive search but in case of non-textual columns this does not have a meaning. |
Problem detection |
system catalog base tables only |
2025-11-07 10:11 |
MIT License |
View |
| 452 |
Generated stored base table columns duplicates another column in the table |
Find generated stored columns in PostgreSQL base tables that duplicate other columns in the table. |
Problem detection |
INFORMATION_SCHEMA only |
2025-11-07 10:11 |
MIT License |
View |
| 453 |
Generated stored base table columns that expression does not refer to any column |
Find generated stored base table columns that expression does not refer to any column of the table. It could be that there will be a constant value in every row in case of this column. The support of generated columns was added to PostgreSQL 12. |
Problem detection |
INFORMATION_SCHEMA only |
2025-11-07 10:11 |
MIT License |
View |
| 454 |
Grantable column privileges |
Find column privileges that the carrier of the privilege can in turn grant to others, i.e., the privileges have been given WITH GRANT OPTION. The number of privileges that can be passed on should be as small as possible. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 455 |
Grantable privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers |
Find privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers that the carrier of the privilege can in turn grant to others, i.e., the privileges have been given WITH GRANT OPTION. The number of privileges that can be passed on should be as small as possible. |
Problem detection |
system catalog base tables only |
2025-11-07 10:11 |
MIT License |
View |
| 456 |
Grantable roles |
Find roles that a member can grant to others, i.e., the role has been granted with ADMIN OPTION. The number of privileges that can be passed on should be as small as possible. |
Problem detection |
system catalog base tables only |
2025-11-07 10:11 |
MIT License |
View |
| 457 |
Grantable routine privileges |
Find routine privileges that the carrier of the privilege can in turn grant to others, i.e., the privileges have been given WITH GRANT OPTION. The number of privileges that can be passed on should be as small as possible. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 458 |
Grantable table privileges |
Find table privileges that the carrier of the privilege can in turn grant to others, i.e., the privileges have been given WITH GRANT OPTION. The number of privileges that can be passed on should be as small as possible. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 459 |
Grantable usage privileges |
Find usage privileges that the carrier of the privilege can in turn grant to others, i.e., the privileges have been given WITH GRANT OPTION. The number of privileges that can be passed on should be as small as possible. |
Problem detection |
INFORMATION_SCHEMA+system catalog base tables |
2025-11-07 10:11 |
MIT License |
View |
| 460 |
Gratuitous context in the names of foreign key columns |
Find foreign key columns that name contains twice the name of the referenced (primary) table. |
Problem detection |
system catalog base tables only |
2025-11-07 10:12 |
MIT License |
View |