Filter Queries

Found 1077 queries.

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

#1021. Redundant indexes sharing an identical leading column

system catalog base tables only

This query identifies redundant, standard (non-expression, non-partial) indexes that share an identical leading column and operator class. In PostgreSQL B-tree indexes, queries filtering on a leading column can utilize any index where that column comes first (the leftmost prefix rule). Having multiple indexes starting with the exact same column and operator class—whether standalone or backing declarative constraints (such as PRIMARY KEY, UNIQUE, or exclusion constraints)—creates overlapping index coverage. This redundancy wastes disk space, consumes buffer cache memory, and introduces unnecessary write overhead on INSERT, UPDATE, and DELETE operations without providing additional query performance benefits.

Problem detection License: MIT (opens in new tab)

#1022. Referential degree of tables (ver 2)

system catalog base tables only

Find how many base tables are referenced from a base table by using foreign keys.

Sofware measure License: MIT (opens in new tab)

#1023. Roles with revoked PUBLIC execute privileges on routines

system catalog base tables only

This query identifies database roles that have explicitly revoked the default EXECUTE privilege from PUBLIC for newly created routines. By default, PostgreSQL automatically grants the EXECUTE privilege to PUBLIC (all users) whenever a new function or procedure is created. Revoking this default behavior is a critical security best practice, ensuring that access to potentially sensitive database logic must be explicitly granted.

General License: MIT (opens in new tab)

#1024. Rules with the same name in different schemas

system catalog base tables only

Find rule names that are used in a database in more than one schema. Different things should have different names. But here different rules have the same name. Also make sure that this is not a duplication.

General License: MIT (opens in new tab)

#1025. Rules with the same name within the same schema

system catalog base tables only

Find names of rules that are used within the same schema more than once. Give different triggers different names.

Problem detection License: MIT (opens in new tab)

#1026. Sequences that are not owned by a table column

system catalog base tables only

Find sequence generators that are not owned by a table column, i.e., if one drops the table or the column, then the sequence generator stays in place.

Problem detection License: MIT (opens in new tab)

#1027. Short cycle (columns)

system catalog base tables only

Find cases where two candidate keys of the same table that are also foreign keys reference to each other.

Problem detection License: MIT (opens in new tab)

#1028. Simple check constraints with multiple tasks

system catalog base tables only

Find simple check constraints, i.e., check constraints that cover one column that seem to have multiple tasks. The corresponding code smell in case of cleaning code is "G30: Functions Should Do One Thing". (Robert C. Martin, Clean Code)

Problem detection License: MIT (opens in new tab)

#1029. Simple primary keys that column name does not contain the table name

system catalog base tables only

Find simple primary keys that column name does not contain the table name. The naming should be clear and consistent.

Problem detection License: MIT (opens in new tab)

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

#1031. Table constraints with the cardinality bigger than one

system catalog base tables only

Find constraints that involve more than one columns. Check as to whether the names follow a common style or not.

General License: MIT (opens in new tab)

#1032. Table inheritance

system catalog base tables only

Find inheritance between base tables. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables.

General License: MIT (opens in new tab)

#1033. Table inheritance (path view)

system catalog base tables only

Find in case of each base table that participates in a table inheritance hierarchy the path to the table from the top-level table. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables. Also make sure that the identifier of each child table in an inheritance hierarchy is a hyponym of the identifier of its parent table.

General License: MIT (opens in new tab)

#1034. Tables that have associated user triggers

system catalog base tables only

Find information about tables that are associated with triggers.

General License: MIT (opens in new tab)

#1035. Temporal function in a simple check constraint is inconsistent with the column type

system catalog base tables only

Find base table columns with a check constraint that refers to a temporal function (current_timestamp, localtimestamp, current_date, or now) that return type is inconsistent with the data type of the column.

Problem detection License: MIT (opens in new tab)

#1036. The expression of a check constraint that is associated with a domain needs type conversion

system catalog base tables only

Find check constraints of domains where the Boolean expression invokes an operation that does not match with the data type of the domain.

Problem detection License: MIT (opens in new tab)

#1037. The longest referential paths

system catalog base tables only

Find the longest referential paths between the tables regardless of the schema that contain the tables.

Sofware measure License: MIT (opens in new tab)

#1038. The number of compensating actions of foreign key constraints

system catalog base tables only

Find the number of compensating actions that are specified in case of foreign key constraints.

Sofware measure License: MIT (opens in new tab)

#1039. The number of direct and indirect child tables (foreign keys)

system catalog base tables only

Find the number of direct and all (direct+indirect) child tables of a base table based on the foreign keys. The result may help to classify the data. If the number of direct children is small but the number of all children is large, then the table probably contains classifiers. If both the number of direct and all children is large, then the table probably contains master data. If the number of all children is small, then the table probably contains transactional data, logs, or descriptive information of main entities.

Sofware measure License: MIT (opens in new tab)

#1040. The number of direct and indirect child tables (table inheritance)

system catalog base tables only

Find the number of direct and all (direct+indirect) child tables of a base table based on the table inheritance.

Sofware measure 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
1021 Redundant indexes sharing an identical leading column This query identifies redundant, standard (non-expression, non-partial) indexes that share an identical leading column and operator class. In PostgreSQL B-tree indexes, queries filtering on a leading column can utilize any index where that column comes first (the leftmost prefix rule). Having multiple indexes starting with the exact same column and operator class—whether standalone or backing declarative constraints (such as PRIMARY KEY, UNIQUE, or exclusion constraints)—creates overlapping index coverage. This redundancy wastes disk space, consumes buffer cache memory, and introduces unnecessary write overhead on INSERT, UPDATE, and DELETE operations without providing additional query performance benefits. Problem detection system catalog base tables only MIT (opens in new tab) View
1022 Referential degree of tables (ver 2) Find how many base tables are referenced from a base table by using foreign keys. Sofware measure system catalog base tables only MIT (opens in new tab) View
1023 Roles with revoked PUBLIC execute privileges on routines This query identifies database roles that have explicitly revoked the default EXECUTE privilege from PUBLIC for newly created routines. By default, PostgreSQL automatically grants the EXECUTE privilege to PUBLIC (all users) whenever a new function or procedure is created. Revoking this default behavior is a critical security best practice, ensuring that access to potentially sensitive database logic must be explicitly granted. General system catalog base tables only MIT (opens in new tab) View
1024 Rules with the same name in different schemas Find rule names that are used in a database in more than one schema. Different things should have different names. But here different rules have the same name. Also make sure that this is not a duplication. General system catalog base tables only MIT (opens in new tab) View
1025 Rules with the same name within the same schema Find names of rules that are used within the same schema more than once. Give different triggers different names. Problem detection system catalog base tables only MIT (opens in new tab) View
1026 Sequences that are not owned by a table column Find sequence generators that are not owned by a table column, i.e., if one drops the table or the column, then the sequence generator stays in place. Problem detection system catalog base tables only MIT (opens in new tab) View
1027 Short cycle (columns) Find cases where two candidate keys of the same table that are also foreign keys reference to each other. Problem detection system catalog base tables only MIT (opens in new tab) View
1028 Simple check constraints with multiple tasks Find simple check constraints, i.e., check constraints that cover one column that seem to have multiple tasks. The corresponding code smell in case of cleaning code is "G30: Functions Should Do One Thing". (Robert C. Martin, Clean Code) Problem detection system catalog base tables only MIT (opens in new tab) View
1029 Simple primary keys that column name does not contain the table name Find simple primary keys that column name does not contain the table name. The naming should be clear and consistent. Problem detection system catalog base tables only MIT (opens in new tab) View
1030 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
1031 Table constraints with the cardinality bigger than one Find constraints that involve more than one columns. Check as to whether the names follow a common style or not. General system catalog base tables only MIT (opens in new tab) View
1032 Table inheritance Find inheritance between base tables. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables. General system catalog base tables only MIT (opens in new tab) View
1033 Table inheritance (path view) Find in case of each base table that participates in a table inheritance hierarchy the path to the table from the top-level table. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables. Also make sure that the identifier of each child table in an inheritance hierarchy is a hyponym of the identifier of its parent table. General system catalog base tables only MIT (opens in new tab) View
1034 Tables that have associated user triggers Find information about tables that are associated with triggers. General system catalog base tables only MIT (opens in new tab) View
1035 Temporal function in a simple check constraint is inconsistent with the column type Find base table columns with a check constraint that refers to a temporal function (current_timestamp, localtimestamp, current_date, or now) that return type is inconsistent with the data type of the column. Problem detection system catalog base tables only MIT (opens in new tab) View
1036 The expression of a check constraint that is associated with a domain needs type conversion Find check constraints of domains where the Boolean expression invokes an operation that does not match with the data type of the domain. Problem detection system catalog base tables only MIT (opens in new tab) View
1037 The longest referential paths Find the longest referential paths between the tables regardless of the schema that contain the tables. Sofware measure system catalog base tables only MIT (opens in new tab) View
1038 The number of compensating actions of foreign key constraints Find the number of compensating actions that are specified in case of foreign key constraints. Sofware measure system catalog base tables only MIT (opens in new tab) View
1039 The number of direct and indirect child tables (foreign keys) Find the number of direct and all (direct+indirect) child tables of a base table based on the foreign keys. The result may help to classify the data. If the number of direct children is small but the number of all children is large, then the table probably contains classifiers. If both the number of direct and all children is large, then the table probably contains master data. If the number of all children is small, then the table probably contains transactional data, logs, or descriptive information of main entities. Sofware measure system catalog base tables only MIT (opens in new tab) View
1040 The number of direct and indirect child tables (table inheritance) Find the number of direct and all (direct+indirect) child tables of a base table based on the table inheritance. Sofware measure system catalog base tables only MIT (opens in new tab) View