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.
#581. Foreign key columns that are associated with a sequence generator
INFORMATION_SCHEMA+system catalog base tablesFind foreign key columns that are associated with a sequence generator. Foreign key values are selected amongst the values that are registered as corresponding primary key/unique key values. Values in the foreign key columns are not directly generated by the system. These values might be system generated indirectly - generated when a row is added to the primary (parent) table.
#582. Foreign key columns that do not have an integer or varchar type
INFORMATION_SCHEMA+system catalog base tablesFind foreign key columns that do not have smallint, integer, bigint, or varchar(n) type. These are the most commonly used types in case of key/foreign key columns. Although the use of other types would be perfectly legal as well, make sure that you have selected the best possible data type for each and every column.
#583. Foreign key columns that have no index
INFORMATION_SCHEMA+system catalog base tablesFind foreign key columns that do not have an index. Foreign key columns are often used for performing join operations. It is useful to index such columns.
#584. Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraint
system catalog base tables onlyFind foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency.
#585. Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraint while the referenced table has the primary key
system catalog base tables onlyFind foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns while at the same time the referenced table does have the primary key. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency.
#586. Foreign key references a non-key (has optional columns)
INFORMATION_SCHEMA+system catalog base tablesFind foreign key constraints that referenced column is optional.
#587. Foreign key references to a unique index columns not a unique key columns
system catalog base tables onlyFind foreign key constraints that reference to the columns that are covered by a unique index not a unique key.
#588. Foreign key refers to a table that has at least one subtable in the inheritance hierarchy
system catalog base tables onlyFind foreign key constraints that refer to a base table that has at least one subtable in the inheritance hierarchy. Rows of the subtable do not belong to the supertable in terms of checking the referential integrity. Let us assume that there is a table T with a subtable Tsub. Let us also assume that table B has a foreign key that refers to the table T. If a row is inserted into Tsub, then this row cannot be referenced from B.
#589. Foreign servers without user mappings
INFORMATION_SCHEMA+system catalog base tablesFind foreign servers that do not have any associated user mappings. "A user mapping typically encapsulates connection information that a foreign-data wrapper uses together with the information encapsulated by a foreign server to access an external data resource."
#590. Frequency of column name lengths based on the table type
INFORMATION_SCHEMA+system catalog base tablesFind in case of base tables, materialized views, and views the number of columns based on the length of the column name.
#591. Frequency of lengths of the names of database objects
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find how many names (identifiers) of database objects there are with different lengths. The values could be used to compare different databases.
#592. Frequency of name components of database objects
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find, what are the most popular components of the names (identifiers) of user-defined database objects, assuming, that the separator of the components is "_".
#593. Frequent names of database objects
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the names (identifiers) of user-defined database objects that occur at least twice as frequently as a name occurs in average. Also make sure that there is no duplication in play.
#594. Frequent names of database objects by object type
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the names (identifiers) of user-defined database objects that occur at least twice as frequently as a name occurs in average in case of the particular type of database objects. Also make sure that there is no duplication in play.
#595. Full text search columns that have no gin or gist index
INFORMATION_SCHEMA+system catalog base tablesFind columns of base tabels and materialized views with the type tsvector that do not have a gin or a gist index. These are the preferred index types for text search.
#596. Full text search columns with other type of index than gin or gist index
INFORMATION_SCHEMA+system catalog base tablesFind columns of base tabels and materialized views with the type tsvector that do not have a gin or a gist index but have another type of index (e.g., b-tree). Gin and Gist are the preferred index types for text search.
#597. Function Upper or Lower is used in an index on a non-textual column
system catalog base tables onlyFind function-based indexes that are based on function Upper or Lower but have been defined on a non-textual column. Such indexes support case insensitive search but in case of non-textual columns this does not have a meaning.
#598. Generated stored base table columns
INFORMATION_SCHEMA onlyFind generated stored columns in PostgreSQL base tables. The support of generated columns was added to PostgreSQL 12. These could be used to improve the performance of queries.
#599. Generated stored base table columns duplicates another column in the table
INFORMATION_SCHEMA onlyFind generated stored columns in PostgreSQL base tables that duplicate other columns in the table.
#600. Generated stored base table columns that expression does not refer to any column
INFORMATION_SCHEMA onlyFind generated stored base table columns that expression does not refer to any column of the table. It could be that there will be a constant value in every row in case of this column. The support of generated columns was added to PostgreSQL 12.
| # | Name(activate to sort ascending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(activate to sort ascending) | Last update(sorted descending, activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 581 | Foreign key columns that are associated with a sequence generator | Find foreign key columns that are associated with a sequence generator. Foreign key values are selected amongst the values that are registered as corresponding primary key/unique key values. Values in the foreign key columns are not directly generated by the system. These values might be system generated indirectly - generated when a row is added to the primary (parent) table. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 582 | Foreign key columns that do not have an integer or varchar type | Find foreign key columns that do not have smallint, integer, bigint, or varchar(n) type. These are the most commonly used types in case of key/foreign key columns. Although the use of other types would be perfectly legal as well, make sure that you have selected the best possible data type for each and every column. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 583 | Foreign key columns that have no index | Find foreign key columns that do not have an index. Foreign key columns are often used for performing join operations. It is useful to index such columns. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 584 | Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraint | Find foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 585 | Foreign key constraint references to the columns of a UNIQUE constraint not to the columns of the PRIMARY KEY constraint while the referenced table has the primary key | Find foreign key constraints that reference to a UNIQUE constraint columns not to the PRIMARY KEY constraint columns while at the same time the referenced table does have the primary key. This is legal in SQL. However, a tradition is to refer to the primary key columns. If most of the foreign keys refer to the primary key columns, then it raises a question as to whether this kind of design decision has a good reason in a particular case or whether it is an inconsistency. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 586 | Foreign key references a non-key (has optional columns) | Find foreign key constraints that referenced column is optional. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 587 | Foreign key references to a unique index columns not a unique key columns | Find foreign key constraints that reference to the columns that are covered by a unique index not a unique key. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 588 | Foreign key refers to a table that has at least one subtable in the inheritance hierarchy | Find foreign key constraints that refer to a base table that has at least one subtable in the inheritance hierarchy. Rows of the subtable do not belong to the supertable in terms of checking the referential integrity. Let us assume that there is a table T with a subtable Tsub. Let us also assume that table B has a foreign key that refers to the table T. If a row is inserted into Tsub, then this row cannot be referenced from B. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 589 | Foreign servers without user mappings | Find foreign servers that do not have any associated user mappings. "A user mapping typically encapsulates connection information that a foreign-data wrapper uses together with the information encapsulated by a foreign server to access an external data resource." | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 590 | Frequency of column name lengths based on the table type | Find in case of base tables, materialized views, and views the number of columns based on the length of the column name. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 591 | Frequency of lengths of the names of database objects | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find how many names (identifiers) of database objects there are with different lengths. The values could be used to compare different databases. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 592 | Frequency of name components of database objects | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find, what are the most popular components of the names (identifiers) of user-defined database objects, assuming, that the separator of the components is "_". | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 593 | Frequent names of database objects | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the names (identifiers) of user-defined database objects that occur at least twice as frequently as a name occurs in average. Also make sure that there is no duplication in play. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 594 | Frequent names of database objects by object type | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the names (identifiers) of user-defined database objects that occur at least twice as frequently as a name occurs in average in case of the particular type of database objects. Also make sure that there is no duplication in play. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 595 | Full text search columns that have no gin or gist index | Find columns of base tabels and materialized views with the type tsvector that do not have a gin or a gist index. These are the preferred index types for text search. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 596 | Full text search columns with other type of index than gin or gist index | Find columns of base tabels and materialized views with the type tsvector that do not have a gin or a gist index but have another type of index (e.g., b-tree). Gin and Gist are the preferred index types for text search. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 597 | Function Upper or Lower is used in an index on a non-textual column | Find function-based indexes that are based on function Upper or Lower but have been defined on a non-textual column. Such indexes support case insensitive search but in case of non-textual columns this does not have a meaning. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 598 | Generated stored base table columns | Find generated stored columns in PostgreSQL base tables. The support of generated columns was added to PostgreSQL 12. These could be used to improve the performance of queries. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 599 | Generated stored base table columns duplicates another column in the table | Find generated stored columns in PostgreSQL base tables that duplicate other columns in the table. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 600 | Generated stored base table columns that expression does not refer to any column | Find generated stored base table columns that expression does not refer to any column of the table. It could be that there will be a constant value in every row in case of this column. The support of generated columns was added to PostgreSQL 12. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View |