Re: Text pattern JOINs that use indexes
От | Richard Brooksby |
---|---|
Тема | Re: Text pattern JOINs that use indexes |
Дата | |
Msg-id | D4104246-76C2-11D8-B40A-000393D3C042@ravenbrook.com обсуждение исходный текст |
Ответ на | Re: Text pattern JOINs that use indexes (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Text pattern JOINs that use indexes
Re: Text pattern JOINs that use indexes |
Список | pgsql-novice |
On 15 Mar 2004, at 19:29, Tom Lane wrote: > Richard Brooksby <rb@ravenbrook.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.
В списке pgsql-novice по дате отправления: