Filter 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.
#1041. The number of referencing base tables
system catalog base tables onlyFind how many base tables reference to a base table by using foreign keys. The more references there are the more impact the change of the table could have to the overall system.
#1042. The number of rules by different characteristics
system catalog base tables onlyFind the number of rules by event (SELECT, INSERT, UPDATE, and DELETE) and in total.
#1043. The number of schema objects by schema, by type, and in total
system catalog base tables onlyFind the number of different types of schema objects in different schemas as well as the total number of schema objects. Show the number of objects that belong to an extension as well as the number of (user-defined) objects that do not belong to an extension.
#1044. The number of table constraints with the cardinality bigger than one
system catalog base tables onlyFind the number of table constraints with the cardinality bigger than one. Find the number, based on the cardinality, constraint type, and cardinality+constraint type.
#1045. The number of user-defined rules
system catalog base tables onlyFind the number of rules in a database, excluding the rules that are associated with system catalog tables and rules that are created to support views. Rules can be used to maintain data integrity in a database by causing rejection of incorrect insertions and updates. Therefore, the number of rules in a database gives some indications about the state of enforcing constraints at the database level.
#1046. The number of user-defined rules by schema and in total
system catalog base tables onlyFind the number of rules in a database in different schemas, excluding the rules that are created to support views. Rules can be used to maintain data integrity in a database by causing rejection of incorrect insertions and updates. Therefore, the number of rules in a database gives an indication about the state of enforcing constraints at the database level.
#1047. The same CHECK has a different name in different places
system catalog base tables onlyFind the names of table CHECK constraints that have the same Boolean expression but a different naming style in different places (tables). The naming of constraints should be consistent. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)x
#1048. The same CHECK has a different name in different places (2)
system catalog base tables onlyThis query audits the database schema to enforce a uniform naming strategy for CHECK constraints. It identifies inconsistencies where constraints enforcing identical Boolean expressions are named using disparate patterns across different tables. To isolate the naming pattern from specific object identifiers, the query normalizes the constraint names by substituting the actual table name with the generic token TABLE. This allows it to detect violations of the "Clean Code" principle of consistency—flagging cases where the same logical rule is implemented with a specific naming convention in one context (e.g., chk_TABLE_column) but a different convention in another (e.g., TABLE_column_check).
#1049. The size of base tables and their indexes
system catalog base tables onlyFind the size of base tables without indexes, size of the indexes of the table, total size of the table (including its indexes) and percentage of the index size from the total size. If the size of indexes of a table is relatively high, then check as to whether all the indexes are needed.
#1050. The storage size of each index (the system catalog excluded)
system catalog base tables onlyGet overview of disk usage.
#1051. The storage size of each schema data object (the system catalog excluded)
system catalog base tables onlyGet overview of disk usage by different schema objects that contain user data.
#1052. The storage size of each table (including indexes) (the system catalog excluded)
system catalog base tables onlyGet overview of disk usage.
#1053. The total size of all indexes (system catalog excluded)
system catalog base tables only#1054. The total size of all tables (system catalog excluded)
system catalog base tables only#1055. The total storage size of all indexes (the system catalog excluded)
system catalog base tables onlyGet overview of disk usage.
#1056. The total storage size of the database (the system catalog included)
system catalog base tables onlyGet overview of disk usage.
#1057. Timezone-aware logic on timezone-unaware columns
system catalog base tables onlyThis query identifies logically flawed CHECK constraints on columns with timezone-unaware data types (DATE and TIMESTAMP WITHOUT TIME ZONE). It specifically targets constraints that contain timezone-aware logic (e.g., using AT TIME ZONE). This represents a critical semantic mismatch: the data type stores a "naive" or "local" time with no timezone context, while the constraint attempts to evaluate it within a specific timezone. The outcome of such a check is non-deterministic, as it depends on the session's current TimeZone setting, leading to unpredictable and unreliable data validation. This is a design flaw; if timezone-aware logic is required, the column should use the TIMESTAMP WITH TIME ZONE (TIMESTAMPTZ) data type.
#1058. Too generic names (candidate key columns)
system catalog base tables onlyFind candidate key columns with the names like id, identifikaator, code, kood, number, etc. The names should have a prefix or a suffix. These are too generic names.
#1059. Too generic names (foreign key columns)
system catalog base tables onlyFind foreign key columns with the names like id, identifikaator, code, kood, number, etc. The names should have a prefix or a suffix that describes the nature of relationship with the referenced table or at least referes to the referenced table. These are too generic names.
#1060. Too generic names (table constraints)
system catalog base tables onlyFind table constraints (constraints that are associated directly with the table) that have too generic names like "key" or the name contain too generic words like "data" (all constraints restrict data in the table), or the name is an abbreviation of a constraint type name.
| # | 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 |
|---|---|---|---|---|---|---|---|
| 1041 | The number of referencing base tables | Find how many base tables reference to a base table by using foreign keys. The more references there are the more impact the change of the table could have to the overall system. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1042 | The number of rules by different characteristics | Find the number of rules by event (SELECT, INSERT, UPDATE, and DELETE) and in total. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1043 | The number of schema objects by schema, by type, and in total | Find the number of different types of schema objects in different schemas as well as the total number of schema objects. Show the number of objects that belong to an extension as well as the number of (user-defined) objects that do not belong to an extension. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1044 | The number of table constraints with the cardinality bigger than one | Find the number of table constraints with the cardinality bigger than one. Find the number, based on the cardinality, constraint type, and cardinality+constraint type. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1045 | The number of user-defined rules | Find the number of rules in a database, excluding the rules that are associated with system catalog tables and rules that are created to support views. Rules can be used to maintain data integrity in a database by causing rejection of incorrect insertions and updates. Therefore, the number of rules in a database gives some indications about the state of enforcing constraints at the database level. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1046 | The number of user-defined rules by schema and in total | Find the number of rules in a database in different schemas, excluding the rules that are created to support views. Rules can be used to maintain data integrity in a database by causing rejection of incorrect insertions and updates. Therefore, the number of rules in a database gives an indication about the state of enforcing constraints at the database level. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1047 | The same CHECK has a different name in different places | Find the names of table CHECK constraints that have the same Boolean expression but a different naming style in different places (tables). The naming of constraints should be consistent. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)x | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 1048 | The same CHECK has a different name in different places (2) | This query audits the database schema to enforce a uniform naming strategy for CHECK constraints. It identifies inconsistencies where constraints enforcing identical Boolean expressions are named using disparate patterns across different tables. To isolate the naming pattern from specific object identifiers, the query normalizes the constraint names by substituting the actual table name with the generic token TABLE. This allows it to detect violations of the "Clean Code" principle of consistency—flagging cases where the same logical rule is implemented with a specific naming convention in one context (e.g., chk_TABLE_column) but a different convention in another (e.g., TABLE_column_check). | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 1049 | The size of base tables and their indexes | Find the size of base tables without indexes, size of the indexes of the table, total size of the table (including its indexes) and percentage of the index size from the total size. If the size of indexes of a table is relatively high, then check as to whether all the indexes are needed. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 1050 | The storage size of each index (the system catalog excluded) | Get overview of disk usage. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1051 | The storage size of each schema data object (the system catalog excluded) | Get overview of disk usage by different schema objects that contain user data. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1052 | The storage size of each table (including indexes) (the system catalog excluded) | Get overview of disk usage. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1053 | The total size of all indexes (system catalog excluded) | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | ||
| 1054 | The total size of all tables (system catalog excluded) | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | ||
| 1055 | The total storage size of all indexes (the system catalog excluded) | Get overview of disk usage. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1056 | The total storage size of the database (the system catalog included) | Get overview of disk usage. | Sofware measure | system catalog base tables only | MIT (opens in new tab) | View | |
| 1057 | Timezone-aware logic on timezone-unaware columns | This query identifies logically flawed CHECK constraints on columns with timezone-unaware data types (DATE and TIMESTAMP WITHOUT TIME ZONE). It specifically targets constraints that contain timezone-aware logic (e.g., using AT TIME ZONE). This represents a critical semantic mismatch: the data type stores a "naive" or "local" time with no timezone context, while the constraint attempts to evaluate it within a specific timezone. The outcome of such a check is non-deterministic, as it depends on the session's current TimeZone setting, leading to unpredictable and unreliable data validation. This is a design flaw; if timezone-aware logic is required, the column should use the TIMESTAMP WITH TIME ZONE (TIMESTAMPTZ) data type. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 1058 | Too generic names (candidate key columns) | Find candidate key columns with the names like id, identifikaator, code, kood, number, etc. The names should have a prefix or a suffix. These are too generic names. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 1059 | Too generic names (foreign key columns) | Find foreign key columns with the names like id, identifikaator, code, kood, number, etc. The names should have a prefix or a suffix that describes the nature of relationship with the referenced table or at least referes to the referenced table. These are too generic names. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 1060 | Too generic names (table constraints) | Find table constraints (constraints that are associated directly with the table) that have too generic names like "key" or the name contain too generic words like "data" (all constraints restrict data in the table), or the name is an abbreviation of a constraint type name. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View |