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: | D4104246-76C2-11D8-B40A-000393D3C042@ravenbrook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
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 files.name 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
enough.
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?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
Yes indeed I have, especially question 4.8!
Thanks again.
From | Date | Subject | |
---|---|---|---|
Next Message | Chris | 2004-03-15 22:08:14 | maxing cpu |
Previous Message | Tom Lane | 2004-03-15 19:29:48 | Re: Text pattern JOINs that use indexes |