Re: optimizing LIKE '%2345' queries

From: Mario Weilguni <mweilguni(at)sime(dot)com>
To: pgsql-performance(at)postgresql(dot)org, genekhart(at)gmail(dot)com
Subject: Re: optimizing LIKE '%2345' queries
Date: 2006-07-03 07:33:53
Message-ID: 200607030933.53373.mweilguni@sime.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Am Sonntag, 2. Juli 2006 23:50 schrieb Gene:
> Is there any way to create a reverse index on string columns so that
> queries of the form:
>
> where column like '%2345';
>
> can use an index and perform as fast as searching with like '2345%'?
>
> Is the only way to create a reverse function and create an index using
> the reverse function and modify queries to use:
>
> where reverse(column) like reverse('%2345') ?
>
> thanks

create a trigger that computes this at insert/update time, index this fix, and
rewrite the query this way:
where inverted_column like '5432%';

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message David Gagnon 2006-07-03 11:41:33 Is postgresql ca do the job for software deployed in ASP ou SaaS mode?
Previous Message Gene 2006-07-02 21:50:37 optimizing LIKE '%2345' queries