Re: Query tuning help - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Query tuning help
Date
Msg-id 200505081748.18362.josh@agliodbs.com
Whole thread Raw
In response to Query tuning help  (Dan Harris <fbsd@drivefaster.net>)
List pgsql-performance
Dan,

>         and (  recordtext like '%RED%' or recordtext like '%CORVETTE%'  )  

It is simply not possible to use B-tree indexes on these kind of text queries.
B-trees require you to start at the "left" side of the field, because B-trees
locate records via <> tests.  "Anywhere in the field" text search requires a
Full Text Index.

> The reason for the redundant LIKE clause is that first, I only want
> those "incidentid"s that contain the words 'RED' and 'CORVETTE'.  BUT,
> those two words may exist across multiple records with the same
> incidentid.  Then, I only want to actually work with the rows that
> contain one of the words.  This query will repeat the same logic for
> however many keywords are entered by the user.  I have investigated
> text searching options and have not found them to be congruous with my
> application.

Sounds like you either need to restructure your application, restructure your
database (so that you're not doing "anywhere in field" searches), or buy 32GB
of ram so that you can cache the whole table.

--
Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-performance by date:

Previous
From: Dan Harris
Date:
Subject: Query tuning help
Next
From: Russell Smith
Date:
Subject: Re: Query tuning help