| Goal | This query identifies standalone indexes—specifically those not backing a declarative constraint (such as a PRIMARY KEY or UNIQUE constraint)—that fail to follow standard naming conventions. It flags indexes that omit both the parent table's full name and its acronym (an abbreviation formed from the initial letters of its name components). Incorporating the table identifier into the index name is crucial: in PostgreSQL, indexes share the schema-wide namespace with tables, meaning this naming practice prevents collisions and provides immediate clarity when inspecting execution plans, performance statistics, or slow query logs. |
|---|---|
| Notes | The query uses DISTINCT to remove duplicate rows in case of composite indexes. |
| Type | Problem detection Each row in the result could represent a flaw in the design |
| Reliability | Medium Medium number of false-positive results |
| License | MIT (opens in new tab) |
| Data Source | system catalog only |
| SQL Query |
|
Fixing Suggestion
Rename the index using ALTER INDEX ... RENAME TO to include the parent table's full name or its standard acronym as a component.
Collections
This query belongs to the following collections:
Find problems about names
A selection of queries that return information about the names of database objects. Contains all the types of queries - problem detection, software measure, and general overview.
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
| Name | Description |
|---|---|
| Find problems about names | A selection of queries that return information about the names of database objects. Contains all the types of queries - problem detection, software measure, and general overview. |
| Find problems automatically | Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not . |
Categories
This query is classified under the following categories:
Comfortability of database evolution
Queries of this category provide information about the means that influence database evolution.
Naming
Queries of this category provide information about the style of naming.
| Name | Description |
|---|---|
| Comfortability of database evolution | Queries of this category provide information about the means that influence database evolution. |
| Naming | Queries of this category provide information about the style of naming. |