For this WHERE, what index to create? WHERE subsidiary_id = 42 AND last_name LIKE '%INA%' Is (subsidiary_id) enough or should it be (subsidiary_id, last_name)? use-the-index-luke.com/sql/clustering…
3
0
13
2K
5
Download Gif
@SQLPerfTips I suspect "it depends". Is subsidiary_id unique? No need for more Is this heavily used? Maybe a covering index clustered on subsidiary_id But for basic usage (subsidiary_id, UPPER(last_name)) should suffice.
@SQLPerfTips btree index on subsidiary_id and gin trigram index on last_name. Use postgres. With this it can use a bitmap OR utilizing both indexes. Depends on data distribution and uniqueness.
@SQLPerfTips I think "LIKE" doesn't use indexes. Because of this index for subsidiary_id is enough.