Filter Queries

Found 1077 queries.

Page 42 of 54
  • 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.

#821. 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)

#822. 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)

#823. 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)

#824. 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)

#825. 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)

#826. 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)

#827. Updatable views that have not been turned to read only

INFORMATION_SCHEMA+system catalog base tables

This query identifies views that are automatically updatable by the database engine but lack explicit safeguards to prevent data modification. Specifically, it targets views that meet the criteria for auto-updatability (typically simple projections of a single base table) yet are missing an INSTEAD OF trigger or a DO INSTEAD NOTHING rule. Without these mechanisms, any INSERT, UPDATE, or DELETE operation performed against the view will seamlessly propagate to the underlying base table, which may violate the intended read-only design contract.

Problem detection License: MIT (opens in new tab)

#828. Updating or deleting data in a routine without restricting rows

INFORMATION_SCHEMA+system catalog base tables

This query identifies user-defined routines that contain unbounded Data Modification Language (DML) statements. Specifically, it flags routines containing UPDATE or DELETE operations that lack a qualifying WHERE clause. Such statements result in full-table modifications, affecting every row in the target relation. While valid in specific maintenance contexts, this pattern typically represents a critical logic error in transactional code, posing a severe risk of unintended massive data loss or corruption.

Problem detection License: MIT (opens in new tab)

#829. Usage of base tables

INFORMATION_SCHEMA+system catalog base tables

Find for each derived table the list of base tables that are used by the derived table.

General License: MIT (opens in new tab)

#830. Usage of the non-standard now() function

INFORMATION_SCHEMA+system catalog base tables

This query identifies all expressions that use the non-standard now() function. In PostgreSQL, now() is a historical, non-standard alias for the SQL-standard current_timestamp. While they are functionally identical within PostgreSQL (both returning the transaction start timestamp as a TIMESTAMPTZ), the use of current_timestamp is strongly preferred for reasons of code portability and adherence to standards. Standardizing on current_timestamp ensures the code is universally understood and easier to maintain or migrate to other database systems.

Problem detection License: MIT (opens in new tab)

#831. Used indexes

INFORMATION_SCHEMA+system catalog base tables

Find indexes that are used by the DBMS.

General License: MIT (opens in new tab)

#832. Useless trivial non-trigger functions

INFORMATION_SCHEMA+system catalog base tables

This query identifies user-defined routines (excluding triggers) that are functionally trivial. It flags routines whose body consists solely of returning a static value: either an input argument (identity function), a constant literal, or NULL. Such routines typically perform no computation, data manipulation, or side effects. They are likely placeholders, deprecated logic, or artifacts of incomplete refactoring, and should be reviewed for removal or implementation.

Problem detection License: MIT (opens in new tab)

#833. Useless trivial trigger functions

INFORMATION_SCHEMA+system catalog base tables

This query identifies trigger functions that are functionally trivial, specifically those whose sole action is to execute RETURN NEW. In a BEFORE trigger context, this operation simply allows the data modification to proceed unchanged. If the function contains no other logic (e.g., validation, modification of NEW, or side effects), it performs no useful work and incurs unnecessary execution overhead. Such triggers are likely incomplete placeholders or obsolete code that should be removed.

Problem detection License: MIT (opens in new tab)

#834. Useless type indication

INFORMATION_SCHEMA+system catalog base tables

Find columns and parameters where the type of the identifier is perhaps explicitly indicated in the name.

Problem detection License: MIT (opens in new tab)

#835. Useless type indication (2)

INFORMATION_SCHEMA+system catalog base tables

Find columns and parameters where the type of the identifier is perhaps explicitly indicated in the name.

Problem detection License: MIT (opens in new tab)

#836. User-defined derived tables

INFORMATION_SCHEMA+system catalog base tables

Find user-defined views and materialized views. Pay attention to the outer join operations. One should use these if and only if there is a real need for them. Otherwise they just reduce performance. On the other hand, pay attention that outer join is used where it is logically needed.

General License: MIT (opens in new tab)

#837. User-defined non-trigger routines without parameters

INFORMATION_SCHEMA+system catalog base tables

Find user-defined non-trigger routines with no parameters.

General License: MIT (opens in new tab)

#838. User-defined non-trigger SQL and PL/pgSQL routines

INFORMATION_SCHEMA+system catalog base tables

This query retrieves a comprehensive list of user-defined routines (functions and procedures) written in SQL or PL/pgSQL. It explicitly filters the result set to exclude:


  • Trigger functions: Routines intended solely for use in triggers are omitted to focus on callable business logic.
  • System schemas: Routines located in system-managed namespaces (e.g., pg_catalog, information_schema) are excluded to isolate user-created code.
  • Extension routines.

The result provides an inventory of the application's explicit, callable database logic.

General License: MIT (opens in new tab)

#839. User-defined routine execution privilege has been granted to PUBLIC

INFORMATION_SCHEMA+system catalog base tables

You should follow the principle of least privilege and thus not have in your database user-defined routines that execution privilege is granted to PUBLIC, i.e., to all the database users now and in the future. By default, PostgreSQL gives routine execution privileges to PUBLIC.

Problem detection License: MIT (opens in new tab)

#840. User-defined routines that have the same name as some system-defined routine.

INFORMATION_SCHEMA+system catalog base tables

Avoid creating user-defined routines that have the same name as some system-defined routine because it may cause confusion.

Problem detection License: MIT (opens in new tab)
# 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
821 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
822 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
823 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
824 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
825 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
826 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
827 Updatable views that have not been turned to read only This query identifies views that are automatically updatable by the database engine but lack explicit safeguards to prevent data modification. Specifically, it targets views that meet the criteria for auto-updatability (typically simple projections of a single base table) yet are missing an INSTEAD OF trigger or a DO INSTEAD NOTHING rule. Without these mechanisms, any INSERT, UPDATE, or DELETE operation performed against the view will seamlessly propagate to the underlying base table, which may violate the intended read-only design contract. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
828 Updating or deleting data in a routine without restricting rows This query identifies user-defined routines that contain unbounded Data Modification Language (DML) statements. Specifically, it flags routines containing UPDATE or DELETE operations that lack a qualifying WHERE clause. Such statements result in full-table modifications, affecting every row in the target relation. While valid in specific maintenance contexts, this pattern typically represents a critical logic error in transactional code, posing a severe risk of unintended massive data loss or corruption. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
829 Usage of base tables Find for each derived table the list of base tables that are used by the derived table. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
830 Usage of the non-standard now() function This query identifies all expressions that use the non-standard now() function. In PostgreSQL, now() is a historical, non-standard alias for the SQL-standard current_timestamp. While they are functionally identical within PostgreSQL (both returning the transaction start timestamp as a TIMESTAMPTZ), the use of current_timestamp is strongly preferred for reasons of code portability and adherence to standards. Standardizing on current_timestamp ensures the code is universally understood and easier to maintain or migrate to other database systems. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
831 Used indexes Find indexes that are used by the DBMS. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
832 Useless trivial non-trigger functions This query identifies user-defined routines (excluding triggers) that are functionally trivial. It flags routines whose body consists solely of returning a static value: either an input argument (identity function), a constant literal, or NULL. Such routines typically perform no computation, data manipulation, or side effects. They are likely placeholders, deprecated logic, or artifacts of incomplete refactoring, and should be reviewed for removal or implementation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
833 Useless trivial trigger functions This query identifies trigger functions that are functionally trivial, specifically those whose sole action is to execute RETURN NEW. In a BEFORE trigger context, this operation simply allows the data modification to proceed unchanged. If the function contains no other logic (e.g., validation, modification of NEW, or side effects), it performs no useful work and incurs unnecessary execution overhead. Such triggers are likely incomplete placeholders or obsolete code that should be removed. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
834 Useless type indication Find columns and parameters where the type of the identifier is perhaps explicitly indicated in the name. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
835 Useless type indication (2) Find columns and parameters where the type of the identifier is perhaps explicitly indicated in the name. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
836 User-defined derived tables Find user-defined views and materialized views. Pay attention to the outer join operations. One should use these if and only if there is a real need for them. Otherwise they just reduce performance. On the other hand, pay attention that outer join is used where it is logically needed. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
837 User-defined non-trigger routines without parameters Find user-defined non-trigger routines with no parameters. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
838 User-defined non-trigger SQL and PL/pgSQL routines This query retrieves a comprehensive list of user-defined routines (functions and procedures) written in SQL or PL/pgSQL. It explicitly filters the result set to exclude:

  • Trigger functions: Routines intended solely for use in triggers are omitted to focus on callable business logic.
  • System schemas: Routines located in system-managed namespaces (e.g., pg_catalog, information_schema) are excluded to isolate user-created code.
  • Extension routines.

The result provides an inventory of the application's explicit, callable database logic.
General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
839 User-defined routine execution privilege has been granted to PUBLIC You should follow the principle of least privilege and thus not have in your database user-defined routines that execution privilege is granted to PUBLIC, i.e., to all the database users now and in the future. By default, PostgreSQL gives routine execution privileges to PUBLIC. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
840 User-defined routines that have the same name as some system-defined routine. Avoid creating user-defined routines that have the same name as some system-defined routine because it may cause confusion. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View