Re: Text pattern JOINs that use indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Brooksby <rb(at)ravenbrook(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Text pattern JOINs that use indexes
Date: 2004-03-15 19:29:48
Message-ID: 25042.1079378988@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Brooksby 2004-03-15 20:53:36 Re: Text pattern JOINs that use indexes
Previous Message Richard Brooksby 2004-03-15 18:48:25 Text pattern JOINs that use indexes