Hello, I want to use Postgres for a fuzzy auto-suggest search field. As
the user will be typing their search phrase, Postgres will show a
list of items that fuzzy-matches what they typed so far, ordered
by popularity (ntile(20)) and distance, i.e. 1 -
word_similarity(). I created a Materialized View with two columns: name text, popularity int. My query at the moment is: SELECT name, popularity Which seems to yield pretty good results, but takes over 40+ ms on a table that's not that large. So I tried to add a GIN trgm index on `name`: CREATE INDEX temp_items3_v_tgrm_item_name ON temp.items3_v USING GIN(name gin_trgm_ops); But it is not used: QUERY
PLAN
| What index would be good for that kind of query? Thanks, Igal Sapir
|