Filter Queries

Found 1053 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 relatively small amount of data, which is in the system catalog of a database.
  • Statistics about the catalog content and project home in GitHub that has additional information.

#921. The number of rules by different characteristics

system catalog base tables only

Find the number of rules by event (SELECT, INSERT, UPDATE, and DELETE) and in total.

Sofware measure License: MIT (opens in new tab)

#922. The number of schema objects by schema, by type, and in total

system catalog base tables only

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 License: MIT (opens in new tab)

#923. The number of sequence generators in different schemas

INFORMATION_SCHEMA only

Identify the number of sequence generators in different schemas. Surrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there are no sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys at the database level. An alternative is to implement generation of unique values at the application level or at the database level by using triggers. However, such implementation would most probably lead to the performance penalty because adding new rows to the table must be serialized, i.e., it can be done in one session at a time.

Sofware measure License: MIT (opens in new tab)

#924. The number of SQL-language routines with different types of bodies

INFORMATION_SCHEMA+system catalog base tables

Find for each user schema that contain a SQL-language routine how many of these have the body that is string literal and how many have the body (possible starting from PostgreSQL 14) that is parsed at the routine definition time. Try to be consistent, i.e., use the same solution in case of all the routines.

Sofware measure License: MIT (opens in new tab)

#925. The number of table constraints with the cardinality bigger than one

system catalog base tables only

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 License: MIT (opens in new tab)

#926. The number of tables based on the number of columns

INFORMATION_SCHEMA+system catalog base tables

Find how many tables with a certain range of the number of columns there are in the database.

Sofware measure License: MIT (opens in new tab)

#927. The number of tables by schema, by type, and in total

INFORMATION_SCHEMA+system catalog base tables

Find the number of tables (base, foreign, and derived) in different schemas.

Sofware measure License: MIT (opens in new tab)

#928. The number of user-defined non-trigger routines by schema, by language, and by routine type

INFORMATION_SCHEMA+system catalog base tables

Find the number of user-defined non-trigger routines based on their schema, language, and routine type. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer.

Sofware measure License: MIT (opens in new tab)

#929. The number of user-defined non-trigger routines by schema, by security type, and by being deterministic

INFORMATION_SCHEMA+system catalog base tables

Find the number of user-defined non-trigger routines based on their schema, security type, and being deterministic. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer.

Sofware measure License: MIT (opens in new tab)

#930. The number of user-defined routines based on their database usage

INFORMATION_SCHEMA+system catalog base tables

Find the number of non-extension routines in a database that modify data. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer. The query distinguishes trigger and non-trigger routines, thus it also gives information about triggers that modify data.

Sofware measure License: MIT (opens in new tab)

#931. The number of user-defined rules

system catalog base tables only

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 License: MIT (opens in new tab)

#932. The number of user-defined rules by schema and in total

system catalog base tables only

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 License: MIT (opens in new tab)

#933. The number of user-defined triggers

INFORMATION_SCHEMA+system catalog base tables

Triggers can be used to maintain data integrity in a database by causing rejection of data that does not conform to certain rules. Therefore, the number of triggers in a database gives some indications about the state of enforcing constraints at the database level. The query does not count internal triggers.

Sofware measure License: MIT (opens in new tab)

#934. The number of user defined triggers by different characteristics

INFORMATION_SCHEMA only

Find the number of user defined triggers by action orientation (ROW, STATEMENT), action timing (BEFORE, AFTER, INSTEAD OF), and event type (INSERT, UPDATE, DELETE) and their combinations.

Sofware measure License: MIT (opens in new tab)

#935. The number of user-defined triggers by schema, by type, and in total

INFORMATION_SCHEMA+system catalog base tables

Triggers can be used to maintain data integrity in a database by causing rejection of data that does not conform to certain rules. Therefore, the number of triggers in a database gives an indication about the state of enforcing constraints at the database level.

Sofware measure License: MIT (opens in new tab)

#936. The proportion of mandatory and optional textual base table columns

INFORMATION_SCHEMA only

Find the number of textual base table columns, the number of optional textual base table columns (permit NULLs), and the number of mandatory textual base table columns (do not permit NULLs).

Sofware measure License: MIT (opens in new tab)

#937. The proportion of using different integer types as types of base table columns

INFORMATION_SCHEMA only

Find the number of base table columns that use different integer types (SMALLINT, INTEGER, BIGINT) and their proportion from the overall set of columns that use an integer type.

Sofware measure License: MIT (opens in new tab)

#938. There is no reason to use PL/pgSQL if you do not use one or more features of a procedural language

INFORMATION_SCHEMA+system catalog base tables

Using PL/pgSQL may cause context switching between declarative SQL and procedural PL/pgSQL. Thus use PL/pgSQL only if you truly need some of its constructs (variables, conditional statements, cycles, cursors, exception handling).

Problem detection License: MIT (opens in new tab)

#939. There is no reason to use PL/pgSQL to write table functions

INFORMATION_SCHEMA+system catalog base tables

Using PL/pgSQL may cause context switching between declarative SQL and procedural PL/pgSQL. Thus use PL/pgSQL only if you truly need some of its constructs. You can create table functions by using SQL.

Problem detection License: MIT (opens in new tab)

#940. The same CHECK has a different name in different places

system catalog base tables only

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 License: MIT (opens in new tab)
# Name Goal Type Data source Last update (sorted descending) License Actions
921 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 (opens in new tab)
922 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 (opens in new tab)
923 The number of sequence generators in different schemas Identify the number of sequence generators in different schemas. Surrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there are no sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys at the database level. An alternative is to implement generation of unique values at the application level or at the database level by using triggers. However, such implementation would most probably lead to the performance penalty because adding new rows to the table must be serialized, i.e., it can be done in one session at a time. Sofware measure INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
924 The number of SQL-language routines with different types of bodies Find for each user schema that contain a SQL-language routine how many of these have the body that is string literal and how many have the body (possible starting from PostgreSQL 14) that is parsed at the routine definition time. Try to be consistent, i.e., use the same solution in case of all the routines. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
925 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 (opens in new tab)
926 The number of tables based on the number of columns Find how many tables with a certain range of the number of columns there are in the database. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
927 The number of tables by schema, by type, and in total Find the number of tables (base, foreign, and derived) in different schemas. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
928 The number of user-defined non-trigger routines by schema, by language, and by routine type Find the number of user-defined non-trigger routines based on their schema, language, and routine type. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
929 The number of user-defined non-trigger routines by schema, by security type, and by being deterministic Find the number of user-defined non-trigger routines based on their schema, security type, and being deterministic. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
930 The number of user-defined routines based on their database usage Find the number of non-extension routines in a database that modify data. The routines can be used to implement virtual data layer. Thus the queriy gives some indications about the possible extent of the layer. The query distinguishes trigger and non-trigger routines, thus it also gives information about triggers that modify data. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
931 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 (opens in new tab)
932 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 (opens in new tab)
933 The number of user-defined triggers Triggers can be used to maintain data integrity in a database by causing rejection of data that does not conform to certain rules. Therefore, the number of triggers in a database gives some indications about the state of enforcing constraints at the database level. The query does not count internal triggers. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
934 The number of user defined triggers by different characteristics Find the number of user defined triggers by action orientation (ROW, STATEMENT), action timing (BEFORE, AFTER, INSTEAD OF), and event type (INSERT, UPDATE, DELETE) and their combinations. Sofware measure INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
935 The number of user-defined triggers by schema, by type, and in total Triggers can be used to maintain data integrity in a database by causing rejection of data that does not conform to certain rules. Therefore, the number of triggers in a database gives an indication about the state of enforcing constraints at the database level. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
936 The proportion of mandatory and optional textual base table columns Find the number of textual base table columns, the number of optional textual base table columns (permit NULLs), and the number of mandatory textual base table columns (do not permit NULLs). Sofware measure INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
937 The proportion of using different integer types as types of base table columns Find the number of base table columns that use different integer types (SMALLINT, INTEGER, BIGINT) and their proportion from the overall set of columns that use an integer type. Sofware measure INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
938 There is no reason to use PL/pgSQL if you do not use one or more features of a procedural language Using PL/pgSQL may cause context switching between declarative SQL and procedural PL/pgSQL. Thus use PL/pgSQL only if you truly need some of its constructs (variables, conditional statements, cycles, cursors, exception handling). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
939 There is no reason to use PL/pgSQL to write table functions Using PL/pgSQL may cause context switching between declarative SQL and procedural PL/pgSQL. Thus use PL/pgSQL only if you truly need some of its constructs. You can create table functions by using SQL. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
940 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 (opens in new tab)