| Goal | Find indexed textual columns where the indexing does not consider the possibility of pattern-based search. Such columns do not have an index where the used operator class makes the index suitable for use by queries involving pattern matching expressions. |
|---|---|
| Notes | The query considers only secondary indexes, i.e., indexes that are non-unique, non-function based, and that do not support any constraint. The query excludes foreign key columns because these are usally not used in pattern-matching queries. |
| Type | Problem detection Each row in the result could represent a flaw in the design |
| Reliability | Low Many false-positive results |
| License | MIT (opens in new tab) |
| Fixing Suggestion | Create an index (instead of the index or in addition to the index) where text, varchar, char columns have the operator class text_pattern_ops, varchar_pattern_ops, or char_pattern_ops, respectively. An example: CREATE INDEX test_index ON test_table (col varchar_pattern_ops); |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
Collections
This query belongs to the following collections:
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 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:
Performance
Queries of this category provide information about indexes in a database.
| Name | Description |
|---|---|
| Performance | Queries of this category provide information about indexes in a database. |
Further reading and related materials: