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
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!
In response to
pgsql-novice by date
|Next:||From: Chris||Date: 2004-03-15 22:08:14|
|Subject: maxing cpu|
|Previous:||From: Tom Lane||Date: 2004-03-15 19:29:48|
|Subject: Re: Text pattern JOINs that use indexes |