Filter Queries

Found 1056 queries.

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

#101. Constraints that are not redefined in a subtable but there is a CHECK constraint that compensates this

INFORMATION_SCHEMA+system catalog base tables

Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Exclude constraints where in case of the subtable there is a CHECK that permits only one specific value in the constraint column. The presence of such check would make the design acceptable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation)

General License: MIT (opens in new tab)

#102. Constraints that are redefined in a subtable.

system catalog base tables only

Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) and have been redefined in its subtable.

General License: MIT (opens in new tab)

#103. Constraint-supporting UNIQUE indexes with the same leading column

system catalog base tables only

Find indexes that support a uniqueness constraint and have the same leading column.

General License: MIT (opens in new tab)

#104. Coverage by derived tables

INFORMATION_SCHEMA+system catalog base tables

Find for each base table the list of derived tables (both views and materialized views) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from the subquery of at least one derived table.

General License: MIT (opens in new tab)

#105. Coverage by routines that have the SQL-standard body

INFORMATION_SCHEMA+system catalog base tables

Find for each base table the list of routines (functions and procedures) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from at least one routine.

General License: MIT (opens in new tab)

#106. Data type usage in the base table columns

INFORMATION_SCHEMA only

Get overview of used data types in the columns of base tables. If the selection is very small then this is a warning sign that perhaps unsuitable types have been used.

General License: MIT (opens in new tab)

#107. Deferrable constraints

system catalog base tables only

Find all deferrable constraints.

General License: MIT (opens in new tab)

#108. Derived tables that have a column with the xid type

INFORMATION_SCHEMA+system catalog base tables

Find the derived tables (views and materialized views) that have a column with the xid type, i.e., these use the data from the hidden xmin column of a base table. If one uses optimistic approach for dealing with the concurrent data modifications, then xmin values should be presented by views and used in routines that modify or delete rows.

General License: MIT (opens in new tab)

#109. Derived tables that present data in json or xml format

INFORMATION_SCHEMA+system catalog base tables

Find views and materialized views that present data in json or xml format. Instead of recording data in this format in base tables one could generate the data value on the fly based on data that has been recorded in base tables.

General License: MIT (opens in new tab)

#110. Derived tables with multiple DISTINCT's

INFORMATION_SCHEMA+system catalog base tables

Find derived tables (views and materialized views) that contain more than one DISTINCT invocation. Make sure that the query is correctly written, including that it does not have unwanted formation of a Cartesian product.

General License: MIT (opens in new tab)

#111. Derived tables with ranking

INFORMATION_SCHEMA+system catalog base tables

Find views and materialized views that use rank and dense_rank window functions.

General License: MIT (opens in new tab)

#112. Derived tables with sorting

INFORMATION_SCHEMA+system catalog base tables

Find derived tables where the rows are ordered, i.e., there is ORDER BY clause at the end of the view. Different users may want to see the rows in different order. Thus, the DBMS may have to do extra and unnecessary work by firstly sorting based on one set of rows and after that based on other set of rows. Use sorting if you know that all the users want the rows in the same order and cannot/will not change the order in the application.

General License: MIT (opens in new tab)

#113. Derived tables with string_agg

INFORMATION_SCHEMA+system catalog base tables

Find views and materialized views that use string_agg aggregate function.

General License: MIT (opens in new tab)

#114. Different non-surrogate key default values

INFORMATION_SCHEMA only

Find the different default values that implement something other than a surrogate key.

General License: MIT (opens in new tab)

#115. Different search paths of SECURITY DEFINER functions

INFORMATION_SCHEMA+system catalog base tables

Find the different search paths used in case of SECURITY DEFINER functions and the number of their occurrences. Make sure that these have been specified correctly and consistently and that they do not refer to any non-existent schemas.

General License: MIT (opens in new tab)

#116. Different tasks of rules

system catalog base tables only

Find different tasks that are solved by using rules, i.e., different rules on the same table or different tables that do the same thing are considered to solve one task.

General License: MIT (opens in new tab)

#117. Different tasks of triggers

INFORMATION_SCHEMA+system catalog base tables

Find different tasks that are solved by using triggers, i.e., different triggers on the same table or different tables that do the same thing are considered to solve one task.

General License: MIT (opens in new tab)

#118. Domain candidates

INFORMATION_SCHEMA+system catalog base tables

Find column descriptions that are candidates for describing a domain.

General License: MIT (opens in new tab)

#119. Domain usage in base tables

INFORMATION_SCHEMA only

Find for each domain the number of usages in base tables. The less you have managed to reuse domains in case of different columns, the more you have wasted your time by creating the domains.

General License: MIT (opens in new tab)

#120. Do not always depend on one's parent

system catalog base tables only

Find where a hierarchical structure is implemented in a base table by adding a foreign key that refers to a candidate key of the same table.

General License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(activate to sort ascending) Type(sorted ascending, activate to sort descending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
101 Constraints that are not redefined in a subtable but there is a CHECK constraint that compensates this Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Exclude constraints where in case of the subtable there is a CHECK that permits only one specific value in the constraint column. The presence of such check would make the design acceptable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation) General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
102 Constraints that are redefined in a subtable. Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) and have been redefined in its subtable. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)
103 Constraint-supporting UNIQUE indexes with the same leading column Find indexes that support a uniqueness constraint and have the same leading column. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)
104 Coverage by derived tables Find for each base table the list of derived tables (both views and materialized views) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from the subquery of at least one derived table. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
105 Coverage by routines that have the SQL-standard body Find for each base table the list of routines (functions and procedures) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from at least one routine. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
106 Data type usage in the base table columns Get overview of used data types in the columns of base tables. If the selection is very small then this is a warning sign that perhaps unsuitable types have been used. General INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
107 Deferrable constraints Find all deferrable constraints. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)
108 Derived tables that have a column with the xid type Find the derived tables (views and materialized views) that have a column with the xid type, i.e., these use the data from the hidden xmin column of a base table. If one uses optimistic approach for dealing with the concurrent data modifications, then xmin values should be presented by views and used in routines that modify or delete rows. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
109 Derived tables that present data in json or xml format Find views and materialized views that present data in json or xml format. Instead of recording data in this format in base tables one could generate the data value on the fly based on data that has been recorded in base tables. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
110 Derived tables with multiple DISTINCT's Find derived tables (views and materialized views) that contain more than one DISTINCT invocation. Make sure that the query is correctly written, including that it does not have unwanted formation of a Cartesian product. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
111 Derived tables with ranking Find views and materialized views that use rank and dense_rank window functions. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
112 Derived tables with sorting Find derived tables where the rows are ordered, i.e., there is ORDER BY clause at the end of the view. Different users may want to see the rows in different order. Thus, the DBMS may have to do extra and unnecessary work by firstly sorting based on one set of rows and after that based on other set of rows. Use sorting if you know that all the users want the rows in the same order and cannot/will not change the order in the application. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
113 Derived tables with string_agg Find views and materialized views that use string_agg aggregate function. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
114 Different non-surrogate key default values Find the different default values that implement something other than a surrogate key. General INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
115 Different search paths of SECURITY DEFINER functions Find the different search paths used in case of SECURITY DEFINER functions and the number of their occurrences. Make sure that these have been specified correctly and consistently and that they do not refer to any non-existent schemas. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
116 Different tasks of rules Find different tasks that are solved by using rules, i.e., different rules on the same table or different tables that do the same thing are considered to solve one task. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)
117 Different tasks of triggers Find different tasks that are solved by using triggers, i.e., different triggers on the same table or different tables that do the same thing are considered to solve one task. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
118 Domain candidates Find column descriptions that are candidates for describing a domain. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
119 Domain usage in base tables Find for each domain the number of usages in base tables. The less you have managed to reuse domains in case of different columns, the more you have wasted your time by creating the domains. General INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
120 Do not always depend on one's parent Find where a hierarchical structure is implemented in a base table by adding a foreign key that refers to a candidate key of the same table. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)