Filter Queries
Found 1056 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.
#201. The shortest 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 shortest (identifiers) names of user-defined objects by their type. These could be the first candidates of renaming in order to give to database objects better names.
#202. The size of base tables and their indexes
system catalog base tables onlyFind the size of base tables without indexes, size of the indexes of the table, total size of the table (including its indexes) and percentage of the index size from the total size. If the size of indexes of a table is relatively high, then check as to whether all the indexes are needed.
#203. The usage of data type formatting functions
INFORMATION_SCHEMA+system catalog base tablesFind expressions that use a data type formatting function - to_char, to_number, to_date, to_timestamp.
#204. Triggers with arguments from the CREATE TRIGGER statement
INFORMATION_SCHEMA+system catalog base tablesFind triggers that get an argument from the CREATE TRIGGER statement.
#205. Triggers with SELECT (i.e., probably check data based on another table)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies trigger functions intended for constraint enforcement that are susceptible to concurrency anomalies due to PostgreSQL's Multi-Version Concurrency Control (MVCC) model. Since read operations (SELECT) do not block write operations, a trigger that validates cross-row constraints without acquiring explicit locks (e.g., LOCK TABLE or SELECT ... FOR UPDATE) involves a race condition. The query detects triggers that query auxiliary data.
#206. Triggers with the same name in different schemas
INFORMATION_SCHEMA+system catalog base tablesFind trigger names that are used in a database in more than one schema. Different things should have different names. But here different triggers have the same name. Also make sure that this is not a duplication.
#207. Unlogged tables
system catalog base tables onlyFind unlogged tables. These may improve the performance of INSERT operations, but with the price of possibly loosing data - an unlogged table is automatically truncated after a crash or unclean shutdown.
#208. Updatable foreign tables that refer to another PostgreSQL table
INFORMATION_SCHEMA onlyThis query identifies foreign tables established via the postgres_fdw (PostgreSQL Foreign Data Wrapper) that are configured to permit data modification (updatability). While postgres_fdw supports INSERT, UPDATE, and DELETE operations on remote tables, enabling this capability introduces complexity regarding distributed transactions, performance, and security. The query serves as an audit tool to verify that the updatability of these foreign tables is a deliberate architectural requirement and not an unintended default configuration.
#209. UPDATE triggers
INFORMATION_SCHEMA onlyFind all UPDATE triggers. Make sure that they specify a correct set of columns in which data modification will fire the trigger.
#210. Usage of base tables
INFORMATION_SCHEMA+system catalog base tablesFind for each derived table the list of base tables that are used by the derived table.
#211. Used indexes
INFORMATION_SCHEMA+system catalog base tablesFind indexes that are used by the DBMS.
#212. User-defined composite types
system catalog base tables onlyFind composite types that are created by a user, i.e., the type is not created automatically by the database management system based on a relation.
#213. User-defined derived tables
INFORMATION_SCHEMA+system catalog base tablesFind user-defined views and materialized views. Pay attention to the outer join operations. One should use these if and only if there is a real need for them. Otherwise they just reduce performance. On the other hand, pay attention that outer join is used where it is logically needed.
#214. User-defined non-trigger routines without parameters
INFORMATION_SCHEMA+system catalog base tablesFind user-defined non-trigger routines with no parameters.
#215. User-defined non-trigger SQL and PL/pgSQL routines
INFORMATION_SCHEMA+system catalog base tablesThis query retrieves a comprehensive list of user-defined routines (functions and procedures) written in SQL or PL/pgSQL. It explicitly filters the result set to exclude:
- Trigger functions: Routines intended solely for use in triggers are omitted to focus on callable business logic.
- System schemas: Routines located in system-managed namespaces (e.g., pg_catalog, information_schema) are excluded to isolate user-created code.
- Extension routines.
The result provides an inventory of the application's explicit, callable database logic.
#216. User-defined routines that implement UPSERT operation
INFORMATION_SCHEMA+system catalog base tablesFind user-defioned routines that implement UPSERT operation. Make sure that it is consistent with the contracts of database operations.
#217. User-defined routines that produce a temporary table
INFORMATION_SCHEMA+system catalog base tablesFind user user-defined routines that produce a temporary table
#218. User-defined routines that read data
INFORMATION_SCHEMA+system catalog base tablesFind user-defined routines that contain SELECT … FROM or PERFORM … FROM operations. PostgreSQL uses multiversion concurrency control (MVCC). Therefore, SELECTs do not block modifications and vice versa. One has to take steps to achieve correct behaviour of data access code. In addition, one should not ask data with multiple queries if it is possible to achieve the result with only one query.
#219. User-defined routines that use xmin hidden column
INFORMATION_SCHEMA+system catalog base tablesFind routines that contain a UPDATE or a DELETE statement that search condition refers to the xmin column. If one uses optimistic approach for dealing with the concurrent modifications of data, then xmin values should be presented by views and used in routines that modify or delete rows.
#220. User-defined routines with dynamic SQL
INFORMATION_SCHEMA+system catalog base tablesFind routines that use dynamic SQL. Make sure that dynamic SQL is indeed needed, i.e., the task cannot be solved with static SQL. Make sure that the routine is protected against attacks that use SQL injection method.
| # | Name(activate to sort ascending) | Goal(activate to sort ascending) | Type(sorted ascending, activate to sort descending) | Data source(activate to sort ascending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 201 | The shortest 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 shortest (identifiers) names of user-defined objects by their type. These could be the first candidates of renaming in order to give to database objects better names. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 202 | The size of base tables and their indexes | Find the size of base tables without indexes, size of the indexes of the table, total size of the table (including its indexes) and percentage of the index size from the total size. If the size of indexes of a table is relatively high, then check as to whether all the indexes are needed. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 203 | The usage of data type formatting functions | Find expressions that use a data type formatting function - to_char, to_number, to_date, to_timestamp. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 204 | Triggers with arguments from the CREATE TRIGGER statement | Find triggers that get an argument from the CREATE TRIGGER statement. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 205 | Triggers with SELECT (i.e., probably check data based on another table) | This query identifies trigger functions intended for constraint enforcement that are susceptible to concurrency anomalies due to PostgreSQL's Multi-Version Concurrency Control (MVCC) model. Since read operations (SELECT) do not block write operations, a trigger that validates cross-row constraints without acquiring explicit locks (e.g., LOCK TABLE or SELECT ... FOR UPDATE) involves a race condition. The query detects triggers that query auxiliary data. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 206 | Triggers with the same name in different schemas | Find trigger names that are used in a database in more than one schema. Different things should have different names. But here different triggers have the same name. Also make sure that this is not a duplication. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 207 | Unlogged tables | Find unlogged tables. These may improve the performance of INSERT operations, but with the price of possibly loosing data - an unlogged table is automatically truncated after a crash or unclean shutdown. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 208 | Updatable foreign tables that refer to another PostgreSQL table | This query identifies foreign tables established via the postgres_fdw (PostgreSQL Foreign Data Wrapper) that are configured to permit data modification (updatability). While postgres_fdw supports INSERT, UPDATE, and DELETE operations on remote tables, enabling this capability introduces complexity regarding distributed transactions, performance, and security. The query serves as an audit tool to verify that the updatability of these foreign tables is a deliberate architectural requirement and not an unintended default configuration. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View (opens in new tab) | |
| 209 | UPDATE triggers | Find all UPDATE triggers. Make sure that they specify a correct set of columns in which data modification will fire the trigger. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View (opens in new tab) | |
| 210 | Usage of base tables | Find for each derived table the list of base tables that are used by the derived table. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 211 | Used indexes | Find indexes that are used by the DBMS. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 212 | User-defined composite types | Find composite types that are created by a user, i.e., the type is not created automatically by the database management system based on a relation. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 213 | User-defined derived tables | Find user-defined views and materialized views. Pay attention to the outer join operations. One should use these if and only if there is a real need for them. Otherwise they just reduce performance. On the other hand, pay attention that outer join is used where it is logically needed. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 214 | User-defined non-trigger routines without parameters | Find user-defined non-trigger routines with no parameters. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 215 | User-defined non-trigger SQL and PL/pgSQL routines | This query retrieves a comprehensive list of user-defined routines (functions and procedures) written in SQL or PL/pgSQL. It explicitly filters the result set to exclude:
The result provides an inventory of the application's explicit, callable database logic. |
General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 216 | User-defined routines that implement UPSERT operation | Find user-defioned routines that implement UPSERT operation. Make sure that it is consistent with the contracts of database operations. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 217 | User-defined routines that produce a temporary table | Find user user-defined routines that produce a temporary table | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 218 | User-defined routines that read data | Find user-defined routines that contain SELECT … FROM or PERFORM … FROM operations. PostgreSQL uses multiversion concurrency control (MVCC). Therefore, SELECTs do not block modifications and vice versa. One has to take steps to achieve correct behaviour of data access code. In addition, one should not ask data with multiple queries if it is possible to achieve the result with only one query. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 219 | User-defined routines that use xmin hidden column | Find routines that contain a UPDATE or a DELETE statement that search condition refers to the xmin column. If one uses optimistic approach for dealing with the concurrent modifications of data, then xmin values should be presented by views and used in routines that modify or delete rows. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 220 | User-defined routines with dynamic SQL | Find routines that use dynamic SQL. Make sure that dynamic SQL is indeed needed, i.e., the task cannot be solved with static SQL. Make sure that the routine is protected against attacks that use SQL injection method. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) |