Catalog of PostgreSQL queries for finding information about a PostgreSQL database and its design problems

AND
AND
AND
ANDFrom where does the query gets its information?
AND
AND

There are 961 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
81Base table columns with DECIMAL (p, s) or NUMERIC (p, s) typeFind base table columns with DECIMAL (p, s) or NUMERIC (p, s) type and make sure that precision p and scale s are not too big or too small.GeneralINFORMATION_SCHEMA only2020-11-06 14:51MIT License
82Base table columns with one of the following types: BIGINT, INTEGER, TEXT, or VARCHAR without max character lengthEach column should have the most appropriate data type. Developers sometimes misuse BIGINT, INTEGER, TEXT or VARCHAR type in places where a type that permits smaller values would be more appropriate and semantically descriptive.GeneralINFORMATION_SCHEMA only2020-11-06 14:51MIT License
83Base table columns with SMALLINT or BOOLEAN typeEach column should have the most appropriate data type. Developers sometimes forget to use SMALLINT type even if it is logically the best choice. Developers also sometimes forget to use BOOLEAN type and instead invent something.GeneralINFORMATION_SCHEMA only2020-11-06 14:51MIT License
84Base table columns with the same name and type have different field sizesFind base table columns that have the same name and type but different field size.Problem detectionINFORMATION_SCHEMA only2021-03-28 16:59MIT License
85Base table columns with the same name have different typesFind base table columns that have the same name but different type. In general, base tables columns that have the same name should have the same type as well.Problem detectionINFORMATION_SCHEMA only2023-01-14 20:54MIT License
86Base table columns with the type VARCHAR(1)The choice of data types should reveal as much as possible about the nature of the data in the column. The type of these columns could be CHAR(1) and they should have a constraint that a value in the column cannot be an empty string.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
87Base table columns with UUID typeEach column should have the most appropriate data type. If one does not want to have in a table the surrogate key that values are generated by using a sequence generator, then one may use instead a column with Universally Unique Identifiers as the key column.GeneralINFORMATION_SCHEMA only2021-03-07 20:57MIT License
88Base table FILLFACTOR is not 100Find all base tables where FILLFACTOR is not 100, i.e., the default value.GeneralINFORMATION_SCHEMA+system catalog base tables2020-11-06 14:51MIT License
89Base table has a national identification number as a keyFind base table columns that name refers to the possibility that these are used to register national identification numbers (personal codes). Find the columns that constitute a key of a table. This in turn enforces a (restrictive) business rule that all persons of interest come from one country. Make sure that the enforced constraint is valid, i.e., there is indeed such rule in the domain.GeneralINFORMATION_SCHEMA+system catalog base tables2020-11-06 14:51MIT License
90Base tables and foreign tables that do not have any CHECK constraints on non-foreign key columnsIdentify possibly missing CHECK constraints.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
91Base tables and foreign tables that have no CHECK constraintsWhat are the base tables and foreign tables without any associated (directly or through domains) check constraints? A NOT NULL constraint is a kind of CHECK constraint. However, this query does not take into account NOT NULL constraints.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
92Base tables and materialized views without any indexFind base tables and materialized views that do not have any index.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-11-05 19:39MIT License
93Base tables created based on a typeFind base tables that have been created based on a composite type and thnk through as to whether it was really needed.Generalsystem catalog base tables only2020-11-06 14:51MIT License
94Base tables that do not have a TOAST tableFind base tables that (due to the types of their columns) do not have an associated TOAST table for storing out-of-line data.Generalsystem catalog base tables only2020-11-06 14:51MIT License
95Base tables that have a surrogate key and all its unique constraints have an optional columnA surrogate key is a primary key that consist of one column. The values of this column do not have any meaning for the user and the system usually generates the values (integers) automatically. In case of defining a surrogate key in a table it is a common mistake to forget declaring existing natural keys in the table. If a key covers an optional column then it does not prevent duplicate rows where some values are missing and other values are equal. Because NULL is not a value and is not duplicate of another NULL the, follwing is possible: CREATE TABLE Uniq(a INTEGER NOT NULL,
b INTEGER,
CONSTRAINT ak_uniq UNIQUE (a, b));

INSERT INTO Uniq(a, b) VALUES (1, NULL);
INSERT INTO Uniq(a, b) VALUES (1, NULL);
Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-10-21 11:54MIT License
96Base tables that have a surrogate key and do not have any uniqueness constraintsA surrogate key is a key that consist of one column. The values of this column do not have any meaning for the user and the system generates the values (integers) automatically. In case of defining a surrogate key in a table it is a common mistake to forget declaring existing natural keys in the table. The query discards tables with only one column.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-10-26 17:47MIT License
97Base tables that have a unique constraint but not the primary keyA common style is to declare in each base table one of the candidate keys as the primary key. All the other candidate keys would be alternate keys that will be enforce with the help of UNIQUE + NOT NULL constraints.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
98Base tables that have more than five indexesFind base tables that have more than five indexes. Indexes can be used to increase the speed of queries (SELECT statements). However, the amount of indexes shouldn't be too large. Otherwise it may reduce the speed of operations that are used to modify data.Problem detectionsystem catalog base tables only2022-10-21 10:33MIT License
99Base tables that have neither a unique constraint nor the primary keyFind base tables without any unique constraints and the primary key. In such tables there are no restrictions for recording duplicate rows. Each row represents a true proposition about the real world. It does not make the proposition truer if one presents it more than once. Moreover, duplicate rows increase data size. Without keys the DBMS lacks vital information about data in the database that it can internally use to choose better execution plans and in this way improve performance of database operations. 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 detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
100Base tables that have no uniqueness requirement for rows whatsoeverFind 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 detectionINFORMATION_SCHEMA+system catalog base tables2022-10-21 10:16MIT License