Filter Queries

Found 1077 queries.

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

#261. Base table columns that lack any simple CHECK, i.e, permit empty strings and strings that consist of only whitespace characters

INFORMATION_SCHEMA+system catalog base tables

This query identifies non-foreign key columns of base tables with a textual data type that lack any simple (single-column) CHECK constraint. The absence of such constraints indicates a complete lack of column-level validation, creating a risk of low-quality data ingress, including the implicit allowance of empty or whitespace-only strings.

Problem detection License: MIT (opens in new tab)

#262. Base table columns with an array type

INFORMATION_SCHEMA+system catalog base tables

Find base table columns with an array type. Think through as to whether a column with an array type could be replaced with a separate table.

General License: MIT (opens in new tab)

#263. Base table FILLFACTOR is not 100

INFORMATION_SCHEMA+system catalog base tables

This query generates a list of all base tables where the FILLFACTOR has been explicitly set to a value other than the default of 100. This non-default setting is a deliberate performance tuning decision, intended to reserve free space within table pages to improve the efficiency of UPDATE operations by facilitating HOT updates. The query provides a comprehensive list for administrators to audit these customizations and verify that they are still necessary and appropriate for the current table workload.

General License: MIT (opens in new tab)

#264. Base table has a national identification number as a key

INFORMATION_SCHEMA+system catalog base tables

This query identifies base table columns whose names suggest they store national identification numbers (personal codes), specifically targeting those that serve as a primary or unique key. Using a national ID as a standalone key enforces a highly restrictive business rule: it assumes that all individuals in the system come from a single country, as identical ID numbers can exist in different countries. The query flags these instances to prompt a review, ensuring that this single-country limitation is intentional and actually aligns with the domain rules.

General License: MIT (opens in new tab)

#265. Base tables and foreign tables that do not have any CHECK constraints on non-foreign key columns

INFORMATION_SCHEMA+system catalog base tables

Identify possibly missing CHECK constraints.

Problem detection License: MIT (opens in new tab)

#266. Base tables and materialized views without any index

INFORMATION_SCHEMA+system catalog base tables

Find base tables and materialized views that do not have any index.

Problem detection License: MIT (opens in new tab)

#267. Base tables that have a surrogate key and all its unique constraints have an optional column

INFORMATION_SCHEMA+system catalog base tables

This query identifies tables with a surrogate primary key (an auto-generated, meaningless single-column identifier) that either lack a natural key entirely or have a flawed natural key constraint. A common design mistake when introducing a surrogate key is forgetting to enforce uniqueness on the actual business identifiers (natural keys). Furthermore, if a UNIQUE constraint includes an optional (nullable) column, it fails to prevent duplicate rows. Because NULL evaluates to an unknown state and is not considered equal to another NULL in standard SQL, multiple rows with identical values and NULLs can be inserted. The query flags these vulnerabilities unless the constraint explicitly uses the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULL values as equal.

Problem detection License: MIT (opens in new tab)

#268. Base tables that have a surrogate key and do not have any uniqueness constraints

INFORMATION_SCHEMA+system catalog base tables

This query identifies tables that use a single-column surrogate primary key but lack any other UNIQUE constraints or unique indexes. The absence of additional unique constraints suggests that the natural business key has not been enforced, creating a risk of data duplication that violates business rules. Tables consisting of only a single column are excluded from this check.

Problem detection License: MIT (opens in new tab)

#269. Base tables that have a unique constraint but not the primary key

INFORMATION_SCHEMA+system catalog base tables

This query identifies leaf base tables (tables with no inheriting children) that possess one or more UNIQUE constraints but lack a defined PRIMARY KEY. It is a standard database design best practice to designate one candidate key as the primary key for every table, treating remaining candidate keys as alternate keys. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables.

Problem detection License: MIT (opens in new tab)

#270. Base tables that have neither a unique constraint nor the primary key

INFORMATION_SCHEMA+system catalog base tables

This query identifies leaf base tables (tables with no inheriting children) that completely lack both PRIMARY KEY and UNIQUE constraints. It is a standard database design best practice to define at least one candidate key and designate it as the primary key for every table. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Instead, parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables.

Problem detection License: MIT (opens in new tab)

#271. Base tables that have no uniqueness requirement for rows whatsoever

INFORMATION_SCHEMA+system catalog base tables

Find base tables without any unique constraints and primary key as well as any unique index, whether it is created explicitly by a developer or automatically by the DBMS. The only legitimate reason of such a table is if it is an abstract table that is used to define common columns of subtables.

Problem detection License: MIT (opens in new tab)

#272. Base tables where all the unique columns are optional

INFORMATION_SCHEMA+system catalog base tables

Find the base tables where all the unique columns are optional. In such tables there can be rows without values that identify these rows. In this case there can be rows in the table where the values that should identify the row are missing.

Problem detection License: MIT (opens in new tab)

#273. Base tables where uniqueness is achieved by using only unique indexes

INFORMATION_SCHEMA+system catalog base tables

Find base tables where uniqueness is achieved by using only unique indexes, i.e., there is at least one unique index but no uniqueness constraints (PRIMARY KEY, UNIQUE, EXCLUDE)

Problem detection License: MIT (opens in new tab)

#274. Base tables, which statistics is probably not up to date

INFORMATION_SCHEMA+system catalog base tables

Find base tables where statistics has not been collected at all or it has been lastly collected more than 40 days ago.

Problem detection License: MIT (opens in new tab)

#275. BEFORE validation triggers inappropriately depending on pg_trigger_depth

INFORMATION_SCHEMA+system catalog base tables

This query identifies BEFORE triggers whose primary purpose is to enforce data integrity and business rules (validating data and raising exceptions without performing any modifying DML operations), but which conditionally bypass execution based on the trigger nesting level (pg_trigger_depth()). Database invariants and business rules must be enforced unconditionally, regardless of whether a data modification was initiated directly by an external client query or indirectly via another trigger, stored procedure, or cascading operation. Because pure validation triggers perform only read operations and do not execute INSERT, UPDATE, DELETE, or MERGE statements, it is mathematically impossible for them to cause infinite recursion. Therefore, incorporating pg_trigger_depth() into validation logic is a severe architectural flaw that creates a critical data integrity loophole: whenever secondary triggers modify the table, all essential validity checks are silently skipped.

Problem detection License: MIT (opens in new tab)

#276. BOOLEAN base table and foreign table columns with a CHECK constraint that involves olnly this column

INFORMATION_SCHEMA+system catalog base tables

Find base table and foreign table columns with the Boolean type that has a CHECK constraint that involves only this column. Avoid unnecessary CHECK constraints. The Boolean type contains only two values and there is nothing to check. By creating a check that determines that possible values in the column are TRUE and FALSE, one duplicates the attribute constraint (column has a type). This is a form of duplication.

Problem detection License: MIT (opens in new tab)

#277. BOOLEAN base table and foreign table columns with a PRIMARY KEY, UNIQUE, or FOREIGN KEY constraint that involves olnly this column

INFORMATION_SCHEMA+system catalog base tables

Find base table columns with the Boolean type that has a PRIMARY KEY, UNIQUE, or FOREIGN KEY constraint that involves only this column. Avoid unnecessary constraints. It is quite improbable that there must be such constraints. For instance, a table with PRIMARY KEY () or UNIQUE () constraint can have at most two rows.

Problem detection License: MIT (opens in new tab)

#278. Candidate key columns that have a static default value

INFORMATION_SCHEMA+system catalog base tables

Find base table columns that are covered by a primary key or a unique constraint and that probably have a static default value.

Problem detection License: MIT (opens in new tab)

#279. Candidate keys where all columns have a static default value

INFORMATION_SCHEMA+system catalog base tables

Find base table primary key and unique constraints where all columns probably have a static default value. Candidate key columns (columns that belong to the primary key or to an unique constraints) shouldn't have static default values unless you are enforcing a rule that a table can have at most one row. The point of default values is that system assigns them automatically. There cannot be multiple rows with the same key value.

Problem detection License: MIT (opens in new tab)

#280. Cannot register all legal e-mail addresses

INFORMATION_SCHEMA+system catalog base tables

Find CHECK constraints on base table or foreign table columns that contain data about e-mail addresses and apply unnecessary restrictions to the these, rejecting potentially some legal addresses. More precisely, find CHECK constraints that prevent registration of e-mail addresses with multiple @ signs.

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
261 Base table columns that lack any simple CHECK, i.e, permit empty strings and strings that consist of only whitespace characters This query identifies non-foreign key columns of base tables with a textual data type that lack any simple (single-column) CHECK constraint. The absence of such constraints indicates a complete lack of column-level validation, creating a risk of low-quality data ingress, including the implicit allowance of empty or whitespace-only strings. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
262 Base table columns with an array type Find base table columns with an array type. Think through as to whether a column with an array type could be replaced with a separate table. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
263 Base table FILLFACTOR is not 100 This query generates a list of all base tables where the FILLFACTOR has been explicitly set to a value other than the default of 100. This non-default setting is a deliberate performance tuning decision, intended to reserve free space within table pages to improve the efficiency of UPDATE operations by facilitating HOT updates. The query provides a comprehensive list for administrators to audit these customizations and verify that they are still necessary and appropriate for the current table workload. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
264 Base table has a national identification number as a key This query identifies base table columns whose names suggest they store national identification numbers (personal codes), specifically targeting those that serve as a primary or unique key. Using a national ID as a standalone key enforces a highly restrictive business rule: it assumes that all individuals in the system come from a single country, as identical ID numbers can exist in different countries. The query flags these instances to prompt a review, ensuring that this single-country limitation is intentional and actually aligns with the domain rules. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
265 Base tables and foreign tables that do not have any CHECK constraints on non-foreign key columns Identify possibly missing CHECK constraints. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
266 Base tables and materialized views without any index Find base tables and materialized views that do not have any index. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
267 Base tables that have a surrogate key and all its unique constraints have an optional column This query identifies tables with a surrogate primary key (an auto-generated, meaningless single-column identifier) that either lack a natural key entirely or have a flawed natural key constraint. A common design mistake when introducing a surrogate key is forgetting to enforce uniqueness on the actual business identifiers (natural keys). Furthermore, if a UNIQUE constraint includes an optional (nullable) column, it fails to prevent duplicate rows. Because NULL evaluates to an unknown state and is not considered equal to another NULL in standard SQL, multiple rows with identical values and NULLs can be inserted. The query flags these vulnerabilities unless the constraint explicitly uses the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULL values as equal. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
268 Base tables that have a surrogate key and do not have any uniqueness constraints This query identifies tables that use a single-column surrogate primary key but lack any other UNIQUE constraints or unique indexes. The absence of additional unique constraints suggests that the natural business key has not been enforced, creating a risk of data duplication that violates business rules. Tables consisting of only a single column are excluded from this check. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
269 Base tables that have a unique constraint but not the primary key This query identifies leaf base tables (tables with no inheriting children) that possess one or more UNIQUE constraints but lack a defined PRIMARY KEY. It is a standard database design best practice to designate one candidate key as the primary key for every table, treating remaining candidate keys as alternate keys. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
270 Base tables that have neither a unique constraint nor the primary key This query identifies leaf base tables (tables with no inheriting children) that completely lack both PRIMARY KEY and UNIQUE constraints. It is a standard database design best practice to define at least one candidate key and designate it as the primary key for every table. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Instead, parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
271 Base tables that have no uniqueness requirement for rows whatsoever Find base tables without any unique constraints and primary key as well as any unique index, whether it is created explicitly by a developer or automatically by the DBMS. The only legitimate reason of such a table is if it is an abstract table that is used to define common columns of subtables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
272 Base tables where all the unique columns are optional Find the base tables where all the unique columns are optional. In such tables there can be rows without values that identify these rows. In this case there can be rows in the table where the values that should identify the row are missing. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
273 Base tables where uniqueness is achieved by using only unique indexes Find base tables where uniqueness is achieved by using only unique indexes, i.e., there is at least one unique index but no uniqueness constraints (PRIMARY KEY, UNIQUE, EXCLUDE) Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
274 Base tables, which statistics is probably not up to date Find base tables where statistics has not been collected at all or it has been lastly collected more than 40 days ago. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
275 BEFORE validation triggers inappropriately depending on pg_trigger_depth This query identifies BEFORE triggers whose primary purpose is to enforce data integrity and business rules (validating data and raising exceptions without performing any modifying DML operations), but which conditionally bypass execution based on the trigger nesting level (pg_trigger_depth()). Database invariants and business rules must be enforced unconditionally, regardless of whether a data modification was initiated directly by an external client query or indirectly via another trigger, stored procedure, or cascading operation. Because pure validation triggers perform only read operations and do not execute INSERT, UPDATE, DELETE, or MERGE statements, it is mathematically impossible for them to cause infinite recursion. Therefore, incorporating pg_trigger_depth() into validation logic is a severe architectural flaw that creates a critical data integrity loophole: whenever secondary triggers modify the table, all essential validity checks are silently skipped. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
276 BOOLEAN base table and foreign table columns with a CHECK constraint that involves olnly this column Find base table and foreign table columns with the Boolean type that has a CHECK constraint that involves only this column. Avoid unnecessary CHECK constraints. The Boolean type contains only two values and there is nothing to check. By creating a check that determines that possible values in the column are TRUE and FALSE, one duplicates the attribute constraint (column has a type). This is a form of duplication. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
277 BOOLEAN base table and foreign table columns with a PRIMARY KEY, UNIQUE, or FOREIGN KEY constraint that involves olnly this column Find base table columns with the Boolean type that has a PRIMARY KEY, UNIQUE, or FOREIGN KEY constraint that involves only this column. Avoid unnecessary constraints. It is quite improbable that there must be such constraints. For instance, a table with PRIMARY KEY () or UNIQUE () constraint can have at most two rows. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
278 Candidate key columns that have a static default value Find base table columns that are covered by a primary key or a unique constraint and that probably have a static default value. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
279 Candidate keys where all columns have a static default value Find base table primary key and unique constraints where all columns probably have a static default value. Candidate key columns (columns that belong to the primary key or to an unique constraints) shouldn't have static default values unless you are enforcing a rule that a table can have at most one row. The point of default values is that system assigns them automatically. There cannot be multiple rows with the same key value. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
280 Cannot register all legal e-mail addresses Find CHECK constraints on base table or foreign table columns that contain data about e-mail addresses and apply unnecessary restrictions to the these, rejecting potentially some legal addresses. More precisely, find CHECK constraints that prevent registration of e-mail addresses with multiple @ signs. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View