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.
#381. Empty columns
INFORMATION_SCHEMA+system catalog base tablesFind columns in non-empty tables that do not contain any values. If there are no values in a columns, then it may mean that one hasn't tested constraints that have been declared to the column or implemented by using triggers. It could also mean that such columns are not needed at all.
#382. Empty schemas
INFORMATION_SCHEMA+system catalog base tablesThis query identifies empty schemas within the database. A schema is considered empty if it exists as a namespace but contains no database objects, such as tables, views, functions, or types. The presence of such schemas often indicates artifacts from failed or incomplete migrations, obsolete application components, or setup errors, and they can be safely removed to reduce schema clutter.
#383. Enumerated or range types with the same name in different schemas
INFORMATION_SCHEMA+system catalog base tablesThis query enforces the Don't Repeat Yorself principle across the database's type system. It identifies ENUM and RANGE types that share the same name but exist in different schemas. This indicates that a conceptual data type has been defined multiple times instead of having a single, canonical definition in a shared schema. Such duplication leads to maintenance overhead and the risk of semantic divergence over time.
#384. Enumerated types with zero or one value
INFORMATION_SCHEMA+system catalog base tablesFidn enumerated types with zero or one value. Type is a named finite set of values. The empty set is a set. A set with one value is a set. Thus, types with zero or one value are legal. In practical terms each type, usually, should contain at least two values.
#385. Excessive classifier name length
INFORMATION_SCHEMA+system catalog base tablesThis query identifies classifier tables where the name column allows strings longer than 100 symbols. Such long names are difficult to read and can cause layout issues in the user interface.
#386. Excessive locking with FOR UPDATE in subqueries
INFORMATION_SCHEMA+system catalog base tablesThis query identifies performance and concurrency bottlenecks caused by excessive locking. It flags INSERT, UPDATE, or DELETE statements that utilize subqueries containing the FOR UPDATE clause. Using FOR UPDATE acquires an exclusive lock, which is semantically inappropriate if the rows in the subquery are merely being read for reference or validation rather than being modified. This practice degrades system concurrency by unnecessarily blocking other transactions.
#387. Exclude constraint to prevent overlapping time periods
INFORMATION_SCHEMA+system catalog base tablesFind exclude constraints on base tables with multiple date/timestamp columns that prevent overlapping time periods.
#388. Explicit execute grants for application roles are missing
INFORMATION_SCHEMA+system catalog base tablesAfter revoking default PUBLIC execution rights, you must explicitly grant the EXECUTE privilege on routines only to the specific users or roles that correspond to your applications. This enforces the principle of least privilege by ensuring that database functions and procedures are accessible exclusively by dedicated service accounts, rather than being open to all database users.
#389. Explicit locking
INFORMATION_SCHEMA+system catalog base tablesThis query identifies user-defined routines that employ explicit locking mechanisms to supplement PostgreSQL's default Multi-Version Concurrency Control (MVCC). It detects the presence of table-level locking (LOCK TABLE) or explicit row-level locking clauses (e.g., SELECT ... FOR UPDATE, FOR SHARE). While MVCC generally provides sufficient isolation for concurrent transactions, explicit locking is necessary in specific race-condition scenarios. This inventory assists in auditing concurrency control strategies and detecting potential sources of deadlocks or serialization bottlenecks.
#390. Explicit locking is missing
INFORMATION_SCHEMA+system catalog base tablesThis query identifies concurrency risks in user-defined routines by flagging INSERT, UPDATE, or DELETE statements that utilize subqueries or Common Table Expressions (WITH clauses) without an explicit FOR SHARE or FOR UPDATE locking clause. Failure to acquire a lock on source rows allows concurrent transactions to modify or delete them between the subquery's execution and the outer data modification, potentially leading to race conditions and data inconsistencies. Routines utilizing the xmin system column or incrementing an explicit row-version column (e.g., version, rea_versioon) are excluded, as they implement Optimistic Concurrency Control (OCC). Additionally, routines that explicitly lock target rows in a preceding SELECT ... FOR UPDATE/SHARE statement immediately prior to a WITH clause are excluded.
#391. Explicit locking is missing (2) (ChatGPT version)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies concurrency risks in user-defined routines by flagging INSERT, UPDATE, or DELETE statements that utilize subqueries without a FOR SHARE locking clause. Failure to acquire a shared lock on source rows allows concurrent transactions to modify or delete them between the subquery's execution and the outer operation, potentially leading to data inconsistencies. Routines utilizing the xmin system column are excluded, operating on the assumption that they implement Optimistic Concurrency Control (version checking) and therefore do not require pessimistic locking.
#392. Explicit search_path in SQL-standard SECURITY DEFINER routines
INFORMATION_SCHEMA+system catalog base tablesThis query identifies SECURITY DEFINER routines defined with a SQL-standard body (introduced in PostgreSQL 14) that explicitly specify a search_path. While setting the search_path is critical for securing older routine types, it is technically redundant for SQL-standard bodies because they securely resolve objects at parse time. Nevertheless, developers might intentionally configure the path to maintain code consistency and improve readability across the database schema.
#393. Explicit SELECT grants on views for application roles are missing
INFORMATION_SCHEMA+system catalog base tablesTo enforce the principle of least privilege, you must explicitly grant SELECT privileges on views only to the specific users or roles that correspond to your applications. Instead of allowing broad access, ensuring that data exposed through views is restricted to dedicated service accounts helps maintain a secure and isolated database architecture.
#394. Extension routines that execution privilege has been granted to PUBLIC
INFORMATION_SCHEMA+system catalog base tablesKnow the privileges that users have in your system. Probably all the database users do not need these privileges.
#395. Extreme contraction
INFORMATION_SCHEMA+system catalog base tablesFind names that contain extremely short terms, due to an excessive word contraction, abbreviation, or acronym usage.
#396. FILLFACTOR is probably too big
INFORMATION_SCHEMA+system catalog base tablesThis query identifies base tables with a potentially suboptimal FILLFACTOR setting, targeting those that likely undergo UPDATE operations. A high FILLFACTOR on such tables can lead to poor performance by reducing the likelihood of Heap-Only Tuple (HOT) updates. When a new row version cannot be stored on the same page as the old version, all indexes on the table must be updated with the new tuple's location.
#397. FILLFACTOR is probably too small
INFORMATION_SCHEMA+system catalog base tablesThis query identifies base tables with a FILLFACTOR setting below 90, flagging them for potentially inefficient storage utilization. While a low FILLFACTOR is intended to accommodate UPDATEs, an excessively low value can lead to wasted disk space and reduced data density, negatively impacting the performance of operations like full table scans.
#398. FILLFACTOR is probably too small (2)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies base tables with a suboptimal FILLFACTOR setting, specifically targeting tables that are heuristically identified as junction tables in a many-to-many relationship. A table is considered a probable junction table if it primarily consists of foreign and primary key columns, with no additional data columns that would suggest UPDATE operations. For these tables, the workload is almost exclusively INSERT and DELETE. Therefore, a FILLFACTOR below 100 serves no performance benefit and results only in wasted storage space and reduced data density.
The job of these linking tables is simple: you add a line to connect two things, or you remove the line to disconnect them. You almost never change a line that's already there. The fillfactor setting is used to leave empty space for changes.
So, if you're leaving empty space in a table where things never change, you're just wasting disk space. This query finds those specific linking tables where you're leaving unnecessary empty space, so you can pack them 100% full and be more efficient.
#399. Find all non-foreign key columns of base tables
INFORMATION_SCHEMA+system catalog base tablesFind all non-foreign key columns of base tables. Make sure that no foreign key constraint is missing.
#400. Find all publications
INFORMATION_SCHEMA+system catalog base tablesFind publications of tables that have been created in order to enable logical replication.
| # | Name(activate to sort ascending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(sorted ascending, activate to sort descending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 381 | Empty columns | Find columns in non-empty tables that do not contain any values. If there are no values in a columns, then it may mean that one hasn't tested constraints that have been declared to the column or implemented by using triggers. It could also mean that such columns are not needed at all. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 382 | Empty schemas | This query identifies empty schemas within the database. A schema is considered empty if it exists as a namespace but contains no database objects, such as tables, views, functions, or types. The presence of such schemas often indicates artifacts from failed or incomplete migrations, obsolete application components, or setup errors, and they can be safely removed to reduce schema clutter. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 383 | Enumerated or range types with the same name in different schemas | This query enforces the Don't Repeat Yorself principle across the database's type system. It identifies ENUM and RANGE types that share the same name but exist in different schemas. This indicates that a conceptual data type has been defined multiple times instead of having a single, canonical definition in a shared schema. Such duplication leads to maintenance overhead and the risk of semantic divergence over time. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 384 | Enumerated types with zero or one value | Fidn enumerated types with zero or one value. Type is a named finite set of values. The empty set is a set. A set with one value is a set. Thus, types with zero or one value are legal. In practical terms each type, usually, should contain at least two values. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 385 | Excessive classifier name length | This query identifies classifier tables where the name column allows strings longer than 100 symbols. Such long names are difficult to read and can cause layout issues in the user interface. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 386 | Excessive locking with FOR UPDATE in subqueries | This query identifies performance and concurrency bottlenecks caused by excessive locking. It flags INSERT, UPDATE, or DELETE statements that utilize subqueries containing the FOR UPDATE clause. Using FOR UPDATE acquires an exclusive lock, which is semantically inappropriate if the rows in the subquery are merely being read for reference or validation rather than being modified. This practice degrades system concurrency by unnecessarily blocking other transactions. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 387 | Exclude constraint to prevent overlapping time periods | Find exclude constraints on base tables with multiple date/timestamp columns that prevent overlapping time periods. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 388 | Explicit execute grants for application roles are missing | After revoking default PUBLIC execution rights, you must explicitly grant the EXECUTE privilege on routines only to the specific users or roles that correspond to your applications. This enforces the principle of least privilege by ensuring that database functions and procedures are accessible exclusively by dedicated service accounts, rather than being open to all database users. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 389 | Explicit locking | This query identifies user-defined routines that employ explicit locking mechanisms to supplement PostgreSQL's default Multi-Version Concurrency Control (MVCC). It detects the presence of table-level locking (LOCK TABLE) or explicit row-level locking clauses (e.g., SELECT ... FOR UPDATE, FOR SHARE). While MVCC generally provides sufficient isolation for concurrent transactions, explicit locking is necessary in specific race-condition scenarios. This inventory assists in auditing concurrency control strategies and detecting potential sources of deadlocks or serialization bottlenecks. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 390 | Explicit locking is missing | This query identifies concurrency risks in user-defined routines by flagging INSERT, UPDATE, or DELETE statements that utilize subqueries or Common Table Expressions (WITH clauses) without an explicit FOR SHARE or FOR UPDATE locking clause. Failure to acquire a lock on source rows allows concurrent transactions to modify or delete them between the subquery's execution and the outer data modification, potentially leading to race conditions and data inconsistencies. Routines utilizing the xmin system column or incrementing an explicit row-version column (e.g., version, rea_versioon) are excluded, as they implement Optimistic Concurrency Control (OCC). Additionally, routines that explicitly lock target rows in a preceding SELECT ... FOR UPDATE/SHARE statement immediately prior to a WITH clause are excluded. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 391 | Explicit locking is missing (2) (ChatGPT version) | This query identifies concurrency risks in user-defined routines by flagging INSERT, UPDATE, or DELETE statements that utilize subqueries without a FOR SHARE locking clause. Failure to acquire a shared lock on source rows allows concurrent transactions to modify or delete them between the subquery's execution and the outer operation, potentially leading to data inconsistencies. Routines utilizing the xmin system column are excluded, operating on the assumption that they implement Optimistic Concurrency Control (version checking) and therefore do not require pessimistic locking. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 392 | Explicit search_path in SQL-standard SECURITY DEFINER routines | This query identifies SECURITY DEFINER routines defined with a SQL-standard body (introduced in PostgreSQL 14) that explicitly specify a search_path. While setting the search_path is critical for securing older routine types, it is technically redundant for SQL-standard bodies because they securely resolve objects at parse time. Nevertheless, developers might intentionally configure the path to maintain code consistency and improve readability across the database schema. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 393 | Explicit SELECT grants on views for application roles are missing | To enforce the principle of least privilege, you must explicitly grant SELECT privileges on views only to the specific users or roles that correspond to your applications. Instead of allowing broad access, ensuring that data exposed through views is restricted to dedicated service accounts helps maintain a secure and isolated database architecture. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 394 | Extension routines that execution privilege has been granted to PUBLIC | Know the privileges that users have in your system. Probably all the database users do not need these privileges. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 395 | Extreme contraction | Find names that contain extremely short terms, due to an excessive word contraction, abbreviation, or acronym usage. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 396 | FILLFACTOR is probably too big | This query identifies base tables with a potentially suboptimal FILLFACTOR setting, targeting those that likely undergo UPDATE operations. A high FILLFACTOR on such tables can lead to poor performance by reducing the likelihood of Heap-Only Tuple (HOT) updates. When a new row version cannot be stored on the same page as the old version, all indexes on the table must be updated with the new tuple's location. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 397 | FILLFACTOR is probably too small | This query identifies base tables with a FILLFACTOR setting below 90, flagging them for potentially inefficient storage utilization. While a low FILLFACTOR is intended to accommodate UPDATEs, an excessively low value can lead to wasted disk space and reduced data density, negatively impacting the performance of operations like full table scans. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 398 | FILLFACTOR is probably too small (2) | This query identifies base tables with a suboptimal FILLFACTOR setting, specifically targeting tables that are heuristically identified as junction tables in a many-to-many relationship. A table is considered a probable junction table if it primarily consists of foreign and primary key columns, with no additional data columns that would suggest UPDATE operations. For these tables, the workload is almost exclusively INSERT and DELETE. Therefore, a FILLFACTOR below 100 serves no performance benefit and results only in wasted storage space and reduced data density. The job of these linking tables is simple: you add a line to connect two things, or you remove the line to disconnect them. You almost never change a line that's already there. The fillfactor setting is used to leave empty space for changes. |
Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 399 | Find all non-foreign key columns of base tables | Find all non-foreign key columns of base tables. Make sure that no foreign key constraint is missing. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 400 | Find all publications | Find publications of tables that have been created in order to enable logical replication. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View |