Filter Queries

Found 1092 queries.

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

#1021. Unnecessary domains

INFORMATION_SCHEMA+system catalog base tables

Domain is a reusable artifact. Effort of its creation should be paid off by the advantages that it offers. If a domain is used in case of at most one column of a base table or even if it is used in case of more than one column but it does not specify neither a default value nor a check constraint, then there is no point of creating the domain.

Problem detection License: MIT (opens in new tab)

#1022. Unnecessary explicit locking in read-only routines

INFORMATION_SCHEMA+system catalog base tables

This query identifies read-only routines that unnecessarily utilize explicit locking mechanisms. PostgreSQL's Multi-Version Concurrency Control (MVCC) ensures that readers do not block writers (and writers do not block readers) during standard query operations. Consequently, routines that perform no data modification (DML) and do not raise exceptions have no functional need to acquire table-level locks (LOCK TABLE) or row-level locks (FOR UPDATE / FOR SHARE). Acquiring locks in purely read-only contexts provides no consistency benefits while actively degrading database concurrency by causing transaction contention. The query explicitly excludes routines whose names indicate they were intentionally designed to handle locking.

Problem detection License: MIT (opens in new tab)

#1023. Unnecessary NULL checks in single-column constraints

INFORMATION_SCHEMA+system catalog base tables

This query identifies single-column CHECK constraints (applied either directly to a base table or through a domain) that explicitly check for NULL values. Constraint definitions should be kept as simple as possible. Because a NULL value causes a logical condition to evaluate to UNKNOWN, and CHECK constraints inherently allow rows that evaluate to either TRUE or UNKNOWN, there is no need to explicitly allow missing values. For instance, instead of writing CHECK (price > 0 OR price IS NULL), the constraint should simply be written as CHECK (price > 0).

Problem detection License: MIT (opens in new tab)

#1024. Unnecessary privileges to use trigger functions

INFORMATION_SCHEMA+system catalog base tables

A user that corresponds to an application does not have to have privileges to use trigger functions. If it has these, then it violates the principle of least privilege.

Problem detection License: MIT (opens in new tab)

#1025. Unnecessary usage of the numeric type in case of base table columns

INFORMATION_SCHEMA only

Find base table columns that have type NUMERIC and the scale is 0, i.e., one can record in the column only integer values. Arithmetic operations are slower in case of the numeric type compared to an integer type. Thus, in order to record integer values, one should use columns with the type SMALLINT, INTEGER, or BIGINT instead of NUMERIC(p,0).

Problem detection License: MIT (opens in new tab)

#1026. Unnecessary usage privileges of PUBLIC

INFORMATION_SCHEMA+system catalog base tables

PostgreSQL gives by default some privileges to all the present and future database users (PUBLIC). Find usage privileges of collations, domains, foreign data wrappers, foreign servers, and sequences that have been given to PUBLIC.

Problem detection License: MIT (opens in new tab)

#1027. Unnecessary use of Coalesce

INFORMATION_SCHEMA+system catalog base tables

This query identifies redundant null-handling logic within string manipulation expressions. It targets the use of explicit coalesce() calls nested inside functions that are already null-safe, such as concat(), concat_ws(), or format(). Since these functions implicitly treat NULL arguments as empty strings (or ignore them), wrapping arguments in coalesce(arg, '') is superfluous. The query deliberately excludes expressions using the standard concatenation operator (||), as coalesce() is legitimately required in that context to prevent null propagation.

Problem detection License: MIT (opens in new tab)

#1028. Unnecessary use of gist index type in case of an exclude constraint

system catalog base tables only

Find exclude constraints that are based on the gist index type although the default b-tree index type would have been enough.

Problem detection License: MIT (opens in new tab)

#1029. Unrestricted default public execution of routines

system catalog base tables only

This query acts as a global security alert. It triggers a warning if no roles in the entire database have explicitly revoked the default PUBLIC execute privileges for newly created routines. In PostgreSQL, new functions and procedures are executable by anyone (PUBLIC) by default. Leaving this unrestricted database-wide violates the principle of least privilege, potentially exposing sensitive business logic or data manipulation routines to unauthorized database users.

Problem detection License: MIT (opens in new tab)

#1030. Unused composite types (for table columns, typed tables, input and output parameters)

system catalog base tables only

Find user-defined composite types that are not used in case of any table, column, and routine (input or otput) parameter (as their type). Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#1031. Unused domains (for base table columns and parameters)

system catalog base tables only

Find domains that are not used in case of any base table column and routine (input or otput) parameter (as their type). Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#1032. Unused enumerated types (for base table columns, domains, and parameters)

INFORMATION_SCHEMA+system catalog base tables

Find enumerated types that are not used in case of any base table column, domain, and routine (input or otput) parameter (as their type). Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#1033. Unused foreign data wrappers

INFORMATION_SCHEMA only

Find foreign data wrappers that do not have any associated foreign servers.

Problem detection License: MIT (opens in new tab)

#1034. Unused foreign servers

INFORMATION_SCHEMA only

Find foreign servers that do not have any associated foreign tables.

Problem detection License: MIT (opens in new tab)

#1035. Unused indexes

INFORMATION_SCHEMA+system catalog base tables

Find indexes that are not used by the DBMS. Remember that indexes are not a "free lunch" and they slow down the processes of updating data.

Problem detection License: MIT (opens in new tab)

#1036. Unused indexes (2)

INFORMATION_SCHEMA+system catalog base tables

Find indexes that are not used by the DBMS. Remember that indexes are not a "free lunch" and they slow down the processes of updating data.

Problem detection License: MIT (opens in new tab)

#1037. Unused named input parameters

INFORMATION_SCHEMA+system catalog base tables

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

#1038. Unused schemas

system catalog base tables only

Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#1039. Unused trigger functions

INFORMATION_SCHEMA+system catalog base tables

Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#1040. Updatable foreign tables that refer to another PostgreSQL table

INFORMATION_SCHEMA only

This query identifies foreign tables established via the postgres_fdw (PostgreSQL Foreign Data Wrapper) that are configured to permit data modification (updatability). While postgres_fdw supports INSERT, UPDATE, and DELETE operations on remote tables, enabling this capability introduces complexity regarding distributed transactions, performance, and security. The query serves as an audit tool to verify that the updatability of these foreign tables is a deliberate architectural requirement and not an unintended default configuration.

General 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
1021 Unnecessary domains Domain is a reusable artifact. Effort of its creation should be paid off by the advantages that it offers. If a domain is used in case of at most one column of a base table or even if it is used in case of more than one column but it does not specify neither a default value nor a check constraint, then there is no point of creating the domain. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1022 Unnecessary explicit locking in read-only routines This query identifies read-only routines that unnecessarily utilize explicit locking mechanisms. PostgreSQL's Multi-Version Concurrency Control (MVCC) ensures that readers do not block writers (and writers do not block readers) during standard query operations. Consequently, routines that perform no data modification (DML) and do not raise exceptions have no functional need to acquire table-level locks (LOCK TABLE) or row-level locks (FOR UPDATE / FOR SHARE). Acquiring locks in purely read-only contexts provides no consistency benefits while actively degrading database concurrency by causing transaction contention. The query explicitly excludes routines whose names indicate they were intentionally designed to handle locking. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1023 Unnecessary NULL checks in single-column constraints This query identifies single-column CHECK constraints (applied either directly to a base table or through a domain) that explicitly check for NULL values. Constraint definitions should be kept as simple as possible. Because a NULL value causes a logical condition to evaluate to UNKNOWN, and CHECK constraints inherently allow rows that evaluate to either TRUE or UNKNOWN, there is no need to explicitly allow missing values. For instance, instead of writing CHECK (price > 0 OR price IS NULL), the constraint should simply be written as CHECK (price > 0). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1024 Unnecessary privileges to use trigger functions A user that corresponds to an application does not have to have privileges to use trigger functions. If it has these, then it violates the principle of least privilege. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1025 Unnecessary usage of the numeric type in case of base table columns Find base table columns that have type NUMERIC and the scale is 0, i.e., one can record in the column only integer values. Arithmetic operations are slower in case of the numeric type compared to an integer type. Thus, in order to record integer values, one should use columns with the type SMALLINT, INTEGER, or BIGINT instead of NUMERIC(p,0). Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
1026 Unnecessary usage privileges of PUBLIC PostgreSQL gives by default some privileges to all the present and future database users (PUBLIC). Find usage privileges of collations, domains, foreign data wrappers, foreign servers, and sequences that have been given to PUBLIC. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1027 Unnecessary use of Coalesce This query identifies redundant null-handling logic within string manipulation expressions. It targets the use of explicit coalesce() calls nested inside functions that are already null-safe, such as concat(), concat_ws(), or format(). Since these functions implicitly treat NULL arguments as empty strings (or ignore them), wrapping arguments in coalesce(arg, '') is superfluous. The query deliberately excludes expressions using the standard concatenation operator (||), as coalesce() is legitimately required in that context to prevent null propagation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1028 Unnecessary use of gist index type in case of an exclude constraint Find exclude constraints that are based on the gist index type although the default b-tree index type would have been enough. Problem detection system catalog base tables only MIT (opens in new tab) View
1029 Unrestricted default public execution of routines This query acts as a global security alert. It triggers a warning if no roles in the entire database have explicitly revoked the default PUBLIC execute privileges for newly created routines. In PostgreSQL, new functions and procedures are executable by anyone (PUBLIC) by default. Leaving this unrestricted database-wide violates the principle of least privilege, potentially exposing sensitive business logic or data manipulation routines to unauthorized database users. Problem detection system catalog base tables only MIT (opens in new tab) View
1030 Unused composite types (for table columns, typed tables, input and output parameters) Find user-defined composite types that are not used in case of any table, column, and routine (input or otput) parameter (as their type). Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code. Problem detection system catalog base tables only MIT (opens in new tab) View
1031 Unused domains (for base table columns and parameters) Find domains that are not used in case of any base table column and routine (input or otput) parameter (as their type). Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code. Problem detection system catalog base tables only MIT (opens in new tab) View
1032 Unused enumerated types (for base table columns, domains, and parameters) Find enumerated types that are not used in case of any base table column, domain, and routine (input or otput) parameter (as their type). Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1033 Unused foreign data wrappers Find foreign data wrappers that do not have any associated foreign servers. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
1034 Unused foreign servers Find foreign servers that do not have any associated foreign tables. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
1035 Unused indexes Find indexes that are not used by the DBMS. Remember that indexes are not a "free lunch" and they slow down the processes of updating data. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1036 Unused indexes (2) Find indexes that are not used by the DBMS. Remember that indexes are not a "free lunch" and they slow down the processes of updating data. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1037 Unused named input parameters Find 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1038 Unused schemas Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code. Problem detection system catalog base tables only MIT (opens in new tab) View
1039 Unused trigger functions Do not keep in your database elements that are not needed by anybody. These should be put in use or dropped, otherwise these are dead code. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
1040 Updatable foreign tables that refer to another PostgreSQL table This query identifies foreign tables established via the postgres_fdw (PostgreSQL Foreign Data Wrapper) that are configured to permit data modification (updatability). While postgres_fdw supports INSERT, UPDATE, and DELETE operations on remote tables, enabling this capability introduces complexity regarding distributed transactions, performance, and security. The query serves as an audit tool to verify that the updatability of these foreign tables is a deliberate architectural requirement and not an unintended default configuration. General INFORMATION_SCHEMA only MIT (opens in new tab) View