From: | Robert DiFalco <robert(dot)difalco(at)gmail(dot)com> |
---|---|
To: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Question about trigram GIST index |
Date: | 2014-12-18 17:12:16 |
Message-ID: | CAAXGW-xxEp=e7M2X+7vWtgT1kvCYe4fgVaAtccDpgyxr91VW6Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
So, for my use case I simply need to search for a case insensitive
substring. It need not be super exact. It seems like there are two ways I
can do this:
CREATE INDEX idx_users_name ON users USING GIST(lower(name) gist_trgm_ops);
SELECT * FROM users WHERE lower(name) LIKE '%john%';
Or I can do it like this:
CREATE INDEX idx_users_name ON users USING GIST(name gist_trgm_ops);
SELECT * FROM users WHERE name % 'john';
Unfortunately I cannot find any documentation on the trade-offs between
these two approaches. For my test dataset of 75K records the query speed
seems pretty damn similar.
So, I guess my question is, what is the difference for querying and insert
for the two approaches?
Thanks!
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-12-18 17:18:52 | Re: Question about trigram GIST index |
Previous Message | Tom Lane | 2014-12-18 17:05:45 | Re: Excessive memory used for INSERT |