Skip site navigation (1) Skip section navigation (2)

Re: Text pattern JOINs that use indexes

From: Richard Brooksby <rb(at)ravenbrook(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Text pattern JOINs that use indexes
Date: 2004-03-15 20:53:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On 15 Mar 2004, at 19:29, Tom Lane wrote:

> Richard Brooksby <rb(at)ravenbrook(dot)com> writes:
>> explain select * from files where name like 'foo%';
> This is indexable because the LIKE pattern is a constant at plan time,
> and so the planner can see that there's a useful range constraint
> extractable from the pattern.
>> explain select * from test join files on like test.filename
>> || '%';
> This is not indexable, because the LIKE pattern is not constant.

Thanks, Tom, I can now see why the planner is making the choice it 
does.  I suppose in theory if I could guarantee that "test.filename" 
didn't contain '%' then the planner could do better, if it was clever 

Do you have a suggestion for how I achieve what I want?  My current 
solution is a function with nested FOR loops, but it seems a great 
shame to have to write it all out by hand.

> TIP 5: Have you checked our extensive FAQ?

Yes indeed I have, especially question 4.8!

Thanks again.

In response to


pgsql-novice by date

Next:From: ChrisDate: 2004-03-15 22:08:14
Subject: maxing cpu
Previous:From: Tom LaneDate: 2004-03-15 19:29:48
Subject: Re: Text pattern JOINs that use indexes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group