I have been seeing quite a large variation in response times regarding LIKE
queries to a particular table in my database. Sometimes I will get results within 200-400 ms (very acceptable) but other times it might take as much as 30 seconds to return results.
I understand that LIKE
queries are very resource intensive but I just don't understand why there would be such a large difference in response times. I have built a btree index on the owner1
field but I don't think it helps with LIKE
queries. Anyone have any ideas?
Sample SQL:
SELECT gid, owner1 FORM parcels
WHERE owner1 ILIKE '%someones name%' LIMIT 10
I've also tried:
SELECT gid, owner1 FROM parcels
WHERE lower(owner1) LIKE lower('%someones name%') LIMIT 10
And:
SELECT gid, owner1 FROM parcels
WHERE lower(owner1) LIKE lower('someones name%') LIMIT 10
With similar results.
Table Row Count: about 95,000.