Re: Help with LIKE - Mailing list pgsql-performance

From Tom Lane
Subject Re: Help with LIKE
Date
Msg-id 8915.1048212381@sss.pgh.pa.us
Whole thread Raw
In response to Re: Help with LIKE  (Josh Berkus <josh@agliodbs.com>)
List pgsql-performance
Josh Berkus <josh@agliodbs.com> writes:
>> SELECT * FROM table WHERE url ~ '^http://.*something.*$';

> That search still requires a seq scan, since it has "gaps" in the seqence of
> characters.  That is,

> url ~ '^http://www.something.*' could use an index, but your search above
> cannot.

Actually, it *can* use an index ... but the index condition will only
use the characters before the ".*", ie, "http://".  Which is just about
useless if you're searching a column of URLs :-(

I agree that tsearch or OpenFTS are the tools to be looking at.

            regards, tom lane

pgsql-performance by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Help with LIKE
Next
From: "Shridhar Daithankar"
Date:
Subject: Re: Page Size in Future Releases