Filter Queries

Found 1096 queries.

Page 18 of 55
  • 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.

#341. Exclude constraint to prevent overlapping time periods

INFORMATION_SCHEMA+system catalog base tables

Find exclude constraints on base tables with multiple date/timestamp columns that prevent overlapping time periods.

General License: MIT (opens in new tab)

#342. Exclusion constraints using upper() instead of lower()

system catalog base tables only

This query identifies exclusion constraints that apply the upper() function to a column. In PostgreSQL, it is a strong community convention to standardize on the lower() function for case-insensitive constraints, indexing, and comparisons. Enforcing this convention ensures consistency across the schema and prevents logical or performance issues (for example, if a developer queries or validates data using lower(col) but the underlying exclusion constraint's index is built on upper(col)).

Problem detection License: MIT (opens in new tab)

#343. Explicit execute grants for application roles are missing

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#344. Explicit locking

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#345. Explicit locking is missing

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#346. Explicit locking is missing (2) (ChatGPT version)

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#347. Explicit search_path in SQL-standard SECURITY DEFINER routines

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#348. Explicit SELECT grants on views for application roles are missing

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#349. Extension routines

system catalog base tables only

Find all routines that belong to an extension.

General License: MIT (opens in new tab)

#350. Extension routines in the schema "public"

system catalog base tables only

Find extensions that routines are in the schema public.

Problem detection License: MIT (opens in new tab)

#351. Extension routines that execution privilege has been granted to PUBLIC

INFORMATION_SCHEMA+system catalog base tables

Know the privileges that users have in your system. Probably all the database users do not need these privileges.

Problem detection License: MIT (opens in new tab)

#352. Extensions that are available but are not installed

system catalog base tables only

Try to use as much the possibilities of the DBMS as possible. On the other hand, do not install extensions that are not needed in order not to overcomplicate the database.

General License: MIT (opens in new tab)

#353. Extreme contraction

INFORMATION_SCHEMA+system catalog base tables

Find names that contain extremely short terms, due to an excessive word contraction, abbreviation, or acronym usage.

Problem detection License: MIT (opens in new tab)

#354. Field size is not sufficiently different in case of base table columns

INFORMATION_SCHEMA only

Find base table columns that name refers to the possibility that these are used to register names. Find base table columns that name refers to the possibility that these are used to register comments/descriptions/etc. Find the cases where a base table contains columns from the both sets and the field size in case of the latter is not at least twice as big as in case of the former. For example, if the name of a service can be 100 character long, then it is quite illogical that the description of the service is only at most 200 characters long.

Problem detection License: MIT (opens in new tab)

#355. FILLFACTOR is probably too big

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#356. FILLFACTOR is probably too small

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#357. FILLFACTOR is probably too small (2)

INFORMATION_SCHEMA+system catalog base tables

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.
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.

Problem detection License: MIT (opens in new tab)

#358. Find all non-foreign key columns of base tables

INFORMATION_SCHEMA+system catalog base tables

Find all non-foreign key columns of base tables. Make sure that no foreign key constraint is missing.

General License: MIT (opens in new tab)

#359. Find all publications

INFORMATION_SCHEMA+system catalog base tables

Find publications of tables that have been created in order to enable logical replication.

General License: MIT (opens in new tab)

#360. Find columns that require new lookup tables (based on names and field sizes)

INFORMATION_SCHEMA+system catalog base tables

This query detects data attributes that function as implicit classifiers but lack a corresponding reference entity. It targets textual columns that are not currently constrained (no PK, UK, or FK) but exhibit characteristics of coded data: they either have a very short length (≤ 3 characters) or possess identifiers typical of classifiers (e.g., 'status', 'type'). To reduce false positives, it excludes obvious free-text fields (names, comments) and verifies that no table with a similar name currently exists. This suggests the need to extract these attributes into a new dedicated reference table to enforce domain integrity.

Problem detection License: MIT (opens in new tab)
# Name(sorted ascending, activate to sort descending) Goal(activate to sort ascending) Type(activate to sort ascending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
341 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
342 Exclusion constraints using upper() instead of lower() This query identifies exclusion constraints that apply the upper() function to a column. In PostgreSQL, it is a strong community convention to standardize on the lower() function for case-insensitive constraints, indexing, and comparisons. Enforcing this convention ensures consistency across the schema and prevents logical or performance issues (for example, if a developer queries or validates data using lower(col) but the underlying exclusion constraint's index is built on upper(col)). Problem detection system catalog base tables only MIT (opens in new tab) View
343 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
344 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
345 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
346 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
347 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
348 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
349 Extension routines Find all routines that belong to an extension. General system catalog base tables only MIT (opens in new tab) View
350 Extension routines in the schema "public" Find extensions that routines are in the schema public. Problem detection system catalog base tables only MIT (opens in new tab) View
351 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
352 Extensions that are available but are not installed Try to use as much the possibilities of the DBMS as possible. On the other hand, do not install extensions that are not needed in order not to overcomplicate the database. General system catalog base tables only MIT (opens in new tab) View
353 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
354 Field size is not sufficiently different in case of base table columns Find base table columns that name refers to the possibility that these are used to register names. Find base table columns that name refers to the possibility that these are used to register comments/descriptions/etc. Find the cases where a base table contains columns from the both sets and the field size in case of the latter is not at least twice as big as in case of the former. For example, if the name of a service can be 100 character long, then it is quite illogical that the description of the service is only at most 200 characters long. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
355 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
356 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
357 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.
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.

Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
358 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
359 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
360 Find columns that require new lookup tables (based on names and field sizes) This query detects data attributes that function as implicit classifiers but lack a corresponding reference entity. It targets textual columns that are not currently constrained (no PK, UK, or FK) but exhibit characteristics of coded data: they either have a very short length (≤ 3 characters) or possess identifiers typical of classifiers (e.g., 'status', 'type'). To reduce false positives, it excludes obvious free-text fields (names, comments) and verifies that no table with a similar name currently exists. This suggests the need to extract these attributes into a new dedicated reference table to enforce domain integrity. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View