Re: full text search index - Mailing list pgsql-general

From Kevin Grittner
Subject Re: full text search index
Date
Msg-id CACjxUsOVzpw9X0zOmBq8ybfZECsMkPXjhLpVQTNUPDRiEWm2mw@mail.gmail.com
Whole thread Raw
In response to full text search index  (Patrick Baker <patrickbakerbr@gmail.com>)
List 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@gmail.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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Subquery uses ungrouped column
Next
From: Ken Winter
Date:
Subject: Aborted pg_dump run empties existing archive file