Filter Queries

Found 1096 queries.

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

#861. Sorting rows based on random values in derived tables without limiting rows

INFORMATION_SCHEMA+system catalog base tables

Find derived tables (views and materialized views) that sort rows based on random values but do not limit the number of rows. This is unnecessary because without sorting the rows are returned in a unspecified order. Sorting based on random values is a computationally expensive operation.

Problem detection License: MIT (opens in new tab)

#862. Sorting rows based on random values in routines

INFORMATION_SCHEMA+system catalog base tables

Find routines that contain a statement that sorts rows based on random values. This can be used to find a random subset of rows. It is a computationally expensive operation.

Problem detection License: MIT (opens in new tab)

#863. Sorting rows based on random values in routines without limiting rows

INFORMATION_SCHEMA+system catalog base tables

Find routines that contain a statement that sorts rows based on random values but do not limit the number of rows. This is unnecessary because without sorting the rows are returned in a unspecified order. Sorting based on random values is a computationally expensive operation.

Problem detection License: MIT (opens in new tab)

#864. SQL function does not return a value

INFORMATION_SCHEMA+system catalog base tables

Find SQL functions that do not return a value (return VOID) but the SQL statement in the function has RETURNING clause.

Problem detection License: MIT (opens in new tab)

#865. STATEMENT level triggers and ROW level AFTER triggers without RETURN NULL

INFORMATION_SCHEMA+system catalog base tables

Write correct code "The return value of a row-level trigger fired AFTER or a statement-level trigger fired BEFORE or AFTER is always ignored; it might as well be null." (PostgreSQL documentation)

Problem detection License: MIT (opens in new tab)

#866. STATEMENT level triggers that refer to the values of row variables NEW or OLD

INFORMATION_SCHEMA+system catalog base tables

Find STATEMENT level triggers that refer to the values of row variables NEW or OLD. NEW and OLD are special variables that can only be used in row-level trigger procedures.

Problem detection License: MIT (opens in new tab)

#867. Stating the obvious

INFORMATION_SCHEMA+system catalog base tables

Find database objects that name contains words "data" or "info". These are noise words because databases are meant for storing and manipulating data/information.

Problem detection License: MIT (opens in new tab)

#868. Stating the obvious (2)

INFORMATION_SCHEMA+system catalog base tables

Find the names of database objects where the name of the database object contains a part of the name of the object type. For instance, the query finds base tables, were the name contains fragments _base, base_, _table, or table_.

Problem detection License: MIT (opens in new tab)

#869. Stating the obvious (column names)

INFORMATION_SCHEMA only

Find the names of columns where the name of the column contains a part of the name of the data type of the column. For instance, the query finds columns, were the name contains fragments integer_ or _integer.

Problem detection License: MIT (opens in new tab)

#870. Storing a duration as time

INFORMATION_SCHEMA only

Find columns of base and foreign tables that based on the column names are used to register durations but the type of the column is time. "It is possible to use a TIME data type if the duration is less than 24 hours, but this is not what the type is intended for, and can be the cause of confusion for the next person who has to maintain your code."

Problem detection License: MIT (opens in new tab)

#871. Storing a duration rather than a point in time

INFORMATION_SCHEMA only

Find columns of base and foreign tables that based on the column names and types are used to register start time and duration rather than start time and end time.

Problem detection License: MIT (opens in new tab)

#872. Storing file content in the database

INFORMATION_SCHEMA only

Find columns that probably store content of files in the database.

General License: MIT (opens in new tab)

#873. Subqueries of derived tables with LIMIT/FETCH/DISTINCT ON without ORDER BY

INFORMATION_SCHEMA+system catalog base tables

Find subqueries of derived tables (views, materialized views) with the LIMIT/FETCH clause or with DISTINCT ON construct but without the ORDER BY clause. These constructs require sorting to produce a meaningful result.

Problem detection License: MIT (opens in new tab)

#874. Superfluous IS NULL checks in constraints

INFORMATION_SCHEMA+system catalog base tables

This query identifies CHECK constraints that contain redundant logic for handling NULLs, a pattern often arising from a misunderstanding of SQL's three-valued logic (TRUE, FALSE, UNKNOWN). A CHECK constraint's condition only fails on FALSE, implicitly permitting NULLs by evaluating comparisons to UNKNOWN. Consequently, an explicit OR column IS NULL clause is tautological and adds no functional value, as demonstrated by the equivalence of CHECK (price IS NULL OR price > 0) and CHECK (price > 0). Removing this superfluous logic improves constraint clarity and eliminates a marginal but unnecessary computational step.

Problem detection License: MIT (opens in new tab)

#875. Surrogate key columns

INFORMATION_SCHEMA+system catalog base tables

Find surrogate keys. Surrogate key is a key that consist of one column, which has an integer type. The key has been declared by using PRIMARY KEY or UNIQUE constraint. The column is associated with a sequence generator (either external or internal, i.e., created by the system automatically because the column has been declared as an identity column). The column does not participate in any foreign key.

General License: MIT (opens in new tab)

#876. Surrogate key columns that do not follow the naming style

INFORMATION_SCHEMA+system catalog base tables

Find surrogate key columns that name does not end with "id_" or start with "id_".

Problem detection License: MIT (opens in new tab)

#877. Surrogate keys in classifier tables

INFORMATION_SCHEMA+system catalog base tables

This query identifies potential classifier (or reference) tables that contain a column populated by a sequence generator. In good database design, tables storing standard reference data should typically use natural keys rather than auto-incrementing surrogate keys.

Problem detection License: MIT (opens in new tab)

#878. Surrogate keys using non-standard SERIAL pseudo-type

INFORMATION_SCHEMA+system catalog base tables

This query identifies surrogate key columns defined using the legacy, PostgreSQL-specific SERIAL (or BIGSERIAL) pseudo-type. While functional, this notation is not part of the ISO SQL standard. The recommended best practice in modern PostgreSQL versions is to utilize GENERATED AS IDENTITY columns. Identity columns are standard-compliant and offer superior management of underlying sequences and permissions compared to the older SERIAL implementation.

Problem detection License: MIT (opens in new tab)

#879. System-generated domain CHECK constraint names

INFORMATION_SCHEMA only

Find the names of domain CHECK constraints that have been system-generated. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different.

Problem detection License: MIT (opens in new tab)

#880. System-generated table constraint names (constraints that involve one column)

system catalog base tables only

Find the names of database constraints that have been system-generated. Additional restrictions are that the constraints must involve only one column and are associated directly with a table (not through a domain). Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different.

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
861 Sorting rows based on random values in derived tables without limiting rows Find derived tables (views and materialized views) that sort rows based on random values but do not limit the number of rows. This is unnecessary because without sorting the rows are returned in a unspecified order. Sorting based on random values is a computationally expensive operation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
862 Sorting rows based on random values in routines Find routines that contain a statement that sorts rows based on random values. This can be used to find a random subset of rows. It is a computationally expensive operation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
863 Sorting rows based on random values in routines without limiting rows Find routines that contain a statement that sorts rows based on random values but do not limit the number of rows. This is unnecessary because without sorting the rows are returned in a unspecified order. Sorting based on random values is a computationally expensive operation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
864 SQL function does not return a value Find SQL functions that do not return a value (return VOID) but the SQL statement in the function has RETURNING clause. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
865 STATEMENT level triggers and ROW level AFTER triggers without RETURN NULL Write correct code "The return value of a row-level trigger fired AFTER or a statement-level trigger fired BEFORE or AFTER is always ignored; it might as well be null." (PostgreSQL documentation) Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
866 STATEMENT level triggers that refer to the values of row variables NEW or OLD Find STATEMENT level triggers that refer to the values of row variables NEW or OLD. NEW and OLD are special variables that can only be used in row-level trigger procedures. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
867 Stating the obvious Find database objects that name contains words "data" or "info". These are noise words because databases are meant for storing and manipulating data/information. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
868 Stating the obvious (2) Find the names of database objects where the name of the database object contains a part of the name of the object type. For instance, the query finds base tables, were the name contains fragments _base, base_, _table, or table_. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
869 Stating the obvious (column names) Find the names of columns where the name of the column contains a part of the name of the data type of the column. For instance, the query finds columns, were the name contains fragments integer_ or _integer. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
870 Storing a duration as time Find columns of base and foreign tables that based on the column names are used to register durations but the type of the column is time. "It is possible to use a TIME data type if the duration is less than 24 hours, but this is not what the type is intended for, and can be the cause of confusion for the next person who has to maintain your code." Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
871 Storing a duration rather than a point in time Find columns of base and foreign tables that based on the column names and types are used to register start time and duration rather than start time and end time. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
872 Storing file content in the database Find columns that probably store content of files in the database. General INFORMATION_SCHEMA only MIT (opens in new tab) View
873 Subqueries of derived tables with LIMIT/FETCH/DISTINCT ON without ORDER BY Find subqueries of derived tables (views, materialized views) with the LIMIT/FETCH clause or with DISTINCT ON construct but without the ORDER BY clause. These constructs require sorting to produce a meaningful result. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
874 Superfluous IS NULL checks in constraints This query identifies CHECK constraints that contain redundant logic for handling NULLs, a pattern often arising from a misunderstanding of SQL's three-valued logic (TRUE, FALSE, UNKNOWN). A CHECK constraint's condition only fails on FALSE, implicitly permitting NULLs by evaluating comparisons to UNKNOWN. Consequently, an explicit OR column IS NULL clause is tautological and adds no functional value, as demonstrated by the equivalence of CHECK (price IS NULL OR price > 0) and CHECK (price > 0). Removing this superfluous logic improves constraint clarity and eliminates a marginal but unnecessary computational step. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
875 Surrogate key columns Find surrogate keys. Surrogate key is a key that consist of one column, which has an integer type. The key has been declared by using PRIMARY KEY or UNIQUE constraint. The column is associated with a sequence generator (either external or internal, i.e., created by the system automatically because the column has been declared as an identity column). The column does not participate in any foreign key. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
876 Surrogate key columns that do not follow the naming style Find surrogate key columns that name does not end with "id_" or start with "id_". Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
877 Surrogate keys in classifier tables This query identifies potential classifier (or reference) tables that contain a column populated by a sequence generator. In good database design, tables storing standard reference data should typically use natural keys rather than auto-incrementing surrogate keys. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
878 Surrogate keys using non-standard SERIAL pseudo-type This query identifies surrogate key columns defined using the legacy, PostgreSQL-specific SERIAL (or BIGSERIAL) pseudo-type. While functional, this notation is not part of the ISO SQL standard. The recommended best practice in modern PostgreSQL versions is to utilize GENERATED AS IDENTITY columns. Identity columns are standard-compliant and offer superior management of underlying sequences and permissions compared to the older SERIAL implementation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
879 System-generated domain CHECK constraint names Find the names of domain CHECK constraints that have been system-generated. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
880 System-generated table constraint names (constraints that involve one column) Find the names of database constraints that have been system-generated. Additional restrictions are that the constraints must involve only one column and are associated directly with a table (not through a domain). Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different. Problem detection system catalog base tables only MIT (opens in new tab) View