From: | Kevin Grittner <kgrittn(at)gmail(dot)com> |
---|---|
To: | Patrick Baker <patrickbakerbr(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: full text search index |
Date: | 2016-05-26 18:31:27 |
Message-ID: | CACjxUsOVzpw9X0zOmBq8ybfZECsMkPXjhLpVQTNUPDRiEWm2mw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You don't provide much context, like PostgreSQL version or machine
characteristics.
https://wiki.postgresql.org/wiki/SlowQueryQuestions
On Wed, May 25, 2016 at 11:04 PM, Patrick Baker
<patrickbakerbr(at)gmail(dot)com> wrote:
>> SELECT COUNT(DISTINCT j0_.id) AS sclr10
>> FROM customers j0_
>> WHERE ((LOWER(j0_.name_first) LIKE '%some%'
>> OR LOWER(j0_.name_last) LIKE '%some%')
>> AND j0_.id = 5)
>> AND j0_.id = 5
>
> The query is taking ages to run.
>
> I read about wildcards and it seems I have to use a function with
> to_tsvector ?
I very much doubt that full text search is going to be helpful here
-- perhaps trigrams with an appropriate gist or gin index could
help. Depending on table sizes and data present, picking out rows
based on the OR of scanning for a sequence of characters in a
couple character string columns might not be your fastest query to
run.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Winter | 2016-05-26 18:48:10 | Aborted pg_dump run empties existing archive file |
Previous Message | Tom Lane | 2016-05-26 16:55:30 | Re: Subquery uses ungrouped column |