Filter Queries

Found 1077 queries.

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

#1001. ON UPDATE CASCADE is probably not needed (based on column names)

system catalog base tables only

This query identifies foreign key constraints with a superfluous ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing surrogate keys should not permit cascading updates, as their values are immutable by definition. The query uses a naming convention to identify probable surrogate keys, specifically flagging foreign key columns with the prefix or suffix "id". The presence of ON UPDATE CASCADE on such keys is not only unnecessary but also misrepresents the nature of the relationship to a schema observer.

Problem detection License: MIT (opens in new tab)

#1002. Optional composite foreign keys that do not have MATCH FULL specified

system catalog base tables only

Find optional composite foreign keys that do not have MATCH FULL specified. Without MATCH FULL the system will permit partial foreign key values

Problem detection License: MIT (opens in new tab)

#1003. Overlapping non-function based indexes that have the same leading column but with different operator class

system catalog base tables only

Find non-function based indexes (both unique and non-unique) that have identical first column but the operator class that is used in case of the first column is different. Include unique indexes that support a constraint (primary key, unique, exclude), i.e., these indexes have been automatically created due to the constraint declaration.

General License: MIT (opens in new tab)

#1004. Patterns of the names of columns of simple primary keys

system catalog base tables only

Find the patterns of the names of columns of simple primary keys. Make sure that the naming is consistent. Ideally, the names should indicate as to whether the column is a surrogate or a natural key column. PostgreSQL 14 added primary keys, unique constraints, and foreign keys to system catalogs. Thus the query was modified to exclude the results from the system catalog.

General License: MIT (opens in new tab)

#1005. Percentage of the total index storage size from the total database storage size (system catalog included)

system catalog base tables only

Get overview of disk usage.

Sofware measure License: MIT (opens in new tab)

#1006. Perhaps an inconsistent use of NO ACTION and RESTRICT in the foreign key declarations

system catalog base tables only

Find as to whether in case of foreign key constraints both the compensating actions RESTRICT and NO ACTION are used within the same database. If the same thing has to do in different places, then try to do it in the same way.

Problem detection License: MIT (opens in new tab)

#1007. Perhaps a relationship should be irreflexive

system catalog base tables only

Enforce all the constraints. A binary relation is called irreflexive, if it does not relate any element to itself.

Problem detection License: MIT (opens in new tab)

#1008. Perhaps a too generic foreign key column name

system catalog base tables only

Find the names of foreign key columns that are too generic. The expressive names of table columns allow database users better and more quickly understand the meaning of data in the database. A person could participate in a process or be associated with an object due to different reasons. Thus, foreign key column names like isik_id, person_id, tootaja_id, worker_id etc. are too generic. The name should refer (also) to the reason why the person is connected.

Problem detection License: MIT (opens in new tab)

#1009. Perhaps primary key columns could be renamed

system catalog base tables only

Find the names of simple primary key columns that name does not follow the pattern _id or _code but it is quite similar.

Problem detection License: MIT (opens in new tab)

#1010. Perhaps unnecessary privileges to use the database

system catalog base tables only

Find as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database.

Problem detection License: MIT (opens in new tab)

#1011. Perhaps un-trimmed string concatenation in derived tables

system catalog base tables only

This query identifies derived tables (views and materialized views) containing string concatenation logic that introduces potential leading or trailing whitespace. It targets expressions using the concatenation operator (||), concat(), or format() that may inject separators (such as spaces) but lack a surrounding trim() function. This pattern often results in "dangling separators" when one of the concatenated components is null or empty, degrading data quality and presentation.

Problem detection License: MIT (opens in new tab)

#1012. Personal names are unique

system catalog base tables only

Find all primary key and unique constraints of base tables that involve at least one column with personal names. Personal names are not unique and these cannot be (usually) used to guarantee uniqueness. Either one has declared a superkey instead of candidate key (i.e., the key contains a column that is not needed for uniqueness) or the key columns have been found incorrectly.

Problem detection License: MIT (opens in new tab)

#1013. Privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers

system catalog base tables only

This query performs a comprehensive security audit of access control lists (ACLs) across a wide range of database objects, including the database itself, schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers. It retrieves privileges granted to any principal other than the object's owner or the systemic postgres superuser. The objective is to identify and validate "third-party" access rights, ensuring compliance with the principle of least privilege and preventing unauthorized access accumulation.

General License: MIT (opens in new tab)

#1014. Privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers that have been granted to a superuser

system catalog base tables only

Find privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers that have been granted to a superuser. Superuser can do anything in the database and thus does not need the privileges. The result is a sign that perhaps the executed GRANT statements were incorrect (wrong username) or the grantee later got superuser status (that it shouldn't have).

Problem detection License: MIT (opens in new tab)

#1015. Publications with no tables

system catalog base tables only

Find publications that do not contain any table.

Problem detection License: MIT (opens in new tab)

#1016. PUBLIC has TEMPORARY privilege in the database

system catalog base tables only

Find as to whether PUBLIC (all current and future users) has TEMPORARY privilege in the database. PUBLIC gets the privilege by default.

Problem detection License: MIT (opens in new tab)

#1017. Public schema privileges granted to PUBLIC

system catalog base tables only

This query checks whether the public schema has CREATE or USAGE privileges granted to the PUBLIC pseudo-role (all database users). While CREATE is a critical vulnerability that allows unprivileged users to create rogue objects in a shared namespace, leaving the USAGE privilege open to PUBLIC is also redundant and violates the principle of least privilege. In a hardened environment, all default ambient access to the public schema should be removed, ensuring that schema traversal and object creation are restricted to explicitly authorized roles.

Problem detection License: MIT (opens in new tab)

#1018. Recursive relationships with the same source and target

system catalog base tables only

Find incorrectly implemented adjacency lists.

Problem detection License: MIT (opens in new tab)

#1019. Recursive rules that directly modify their home table

system catalog base tables only

Do not cause potentially infinite loops. Recursive rules would fire itself over and over again. Although the system is able to detect these after executing a data modification statement it is better to avoid creating these altogether.

Problem detection License: MIT (opens in new tab)

#1020. Redundant indexes

system catalog base tables only

Find indexes that may be redundant. In addition to identical indexes it also considers indexes that cover the same columns and have the same properties except uniqueness. The query considers all types of indexes, including indexes that have been automatically created to support a constraint and function-based indexes.

Problem detection 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
1001 ON UPDATE CASCADE is probably not needed (based on column names) This query identifies foreign key constraints with a superfluous ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing surrogate keys should not permit cascading updates, as their values are immutable by definition. The query uses a naming convention to identify probable surrogate keys, specifically flagging foreign key columns with the prefix or suffix "id". The presence of ON UPDATE CASCADE on such keys is not only unnecessary but also misrepresents the nature of the relationship to a schema observer. Problem detection system catalog base tables only MIT (opens in new tab) View
1002 Optional composite foreign keys that do not have MATCH FULL specified Find optional composite foreign keys that do not have MATCH FULL specified. Without MATCH FULL the system will permit partial foreign key values Problem detection system catalog base tables only MIT (opens in new tab) View
1003 Overlapping non-function based indexes that have the same leading column but with different operator class Find non-function based indexes (both unique and non-unique) that have identical first column but the operator class that is used in case of the first column is different. Include unique indexes that support a constraint (primary key, unique, exclude), i.e., these indexes have been automatically created due to the constraint declaration. General system catalog base tables only MIT (opens in new tab) View
1004 Patterns of the names of columns of simple primary keys Find the patterns of the names of columns of simple primary keys. Make sure that the naming is consistent. Ideally, the names should indicate as to whether the column is a surrogate or a natural key column. PostgreSQL 14 added primary keys, unique constraints, and foreign keys to system catalogs. Thus the query was modified to exclude the results from the system catalog. General system catalog base tables only MIT (opens in new tab) View
1005 Percentage of the total index storage size from the total database storage size (system catalog included) Get overview of disk usage. Sofware measure system catalog base tables only MIT (opens in new tab) View
1006 Perhaps an inconsistent use of NO ACTION and RESTRICT in the foreign key declarations Find as to whether in case of foreign key constraints both the compensating actions RESTRICT and NO ACTION are used within the same database. If the same thing has to do in different places, then try to do it in the same way. Problem detection system catalog base tables only MIT (opens in new tab) View
1007 Perhaps a relationship should be irreflexive Enforce all the constraints. A binary relation is called irreflexive, if it does not relate any element to itself. Problem detection system catalog base tables only MIT (opens in new tab) View
1008 Perhaps a too generic foreign key column name Find the names of foreign key columns that are too generic. The expressive names of table columns allow database users better and more quickly understand the meaning of data in the database. A person could participate in a process or be associated with an object due to different reasons. Thus, foreign key column names like isik_id, person_id, tootaja_id, worker_id etc. are too generic. The name should refer (also) to the reason why the person is connected. Problem detection system catalog base tables only MIT (opens in new tab) View
1009 Perhaps primary key columns could be renamed Find the names of simple primary key columns that name does not follow the pattern _id or _code but it is quite similar. Problem detection system catalog base tables only MIT (opens in new tab) View
1010 Perhaps unnecessary privileges to use the database Find as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database. Problem detection system catalog base tables only MIT (opens in new tab) View
1011 Perhaps un-trimmed string concatenation in derived tables This query identifies derived tables (views and materialized views) containing string concatenation logic that introduces potential leading or trailing whitespace. It targets expressions using the concatenation operator (||), concat(), or format() that may inject separators (such as spaces) but lack a surrounding trim() function. This pattern often results in "dangling separators" when one of the concatenated components is null or empty, degrading data quality and presentation. Problem detection system catalog base tables only MIT (opens in new tab) View
1012 Personal names are unique Find all primary key and unique constraints of base tables that involve at least one column with personal names. Personal names are not unique and these cannot be (usually) used to guarantee uniqueness. Either one has declared a superkey instead of candidate key (i.e., the key contains a column that is not needed for uniqueness) or the key columns have been found incorrectly. Problem detection system catalog base tables only MIT (opens in new tab) View
1013 Privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers This query performs a comprehensive security audit of access control lists (ACLs) across a wide range of database objects, including the database itself, schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers. It retrieves privileges granted to any principal other than the object's owner or the systemic postgres superuser. The objective is to identify and validate "third-party" access rights, ensuring compliance with the principle of least privilege and preventing unauthorized access accumulation. General system catalog base tables only MIT (opens in new tab) View
1014 Privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers that have been granted to a superuser Find privileges on the database and its schemas, domains, types, languages, sequences, foreign data wrappers, and foreign servers that have been granted to a superuser. Superuser can do anything in the database and thus does not need the privileges. The result is a sign that perhaps the executed GRANT statements were incorrect (wrong username) or the grantee later got superuser status (that it shouldn't have). Problem detection system catalog base tables only MIT (opens in new tab) View
1015 Publications with no tables Find publications that do not contain any table. Problem detection system catalog base tables only MIT (opens in new tab) View
1016 PUBLIC has TEMPORARY privilege in the database Find as to whether PUBLIC (all current and future users) has TEMPORARY privilege in the database. PUBLIC gets the privilege by default. Problem detection system catalog base tables only MIT (opens in new tab) View
1017 Public schema privileges granted to PUBLIC This query checks whether the public schema has CREATE or USAGE privileges granted to the PUBLIC pseudo-role (all database users). While CREATE is a critical vulnerability that allows unprivileged users to create rogue objects in a shared namespace, leaving the USAGE privilege open to PUBLIC is also redundant and violates the principle of least privilege. In a hardened environment, all default ambient access to the public schema should be removed, ensuring that schema traversal and object creation are restricted to explicitly authorized roles. Problem detection system catalog base tables only MIT (opens in new tab) View
1018 Recursive relationships with the same source and target Find incorrectly implemented adjacency lists. Problem detection system catalog base tables only MIT (opens in new tab) View
1019 Recursive rules that directly modify their home table Do not cause potentially infinite loops. Recursive rules would fire itself over and over again. Although the system is able to detect these after executing a data modification statement it is better to avoid creating these altogether. Problem detection system catalog base tables only MIT (opens in new tab) View
1020 Redundant indexes Find indexes that may be redundant. In addition to identical indexes it also considers indexes that cover the same columns and have the same properties except uniqueness. The query considers all types of indexes, including indexes that have been automatically created to support a constraint and function-based indexes. Problem detection system catalog base tables only MIT (opens in new tab) View