Re: index not used with subselect in where clause ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rod Taylor" <rod(dot)taylor(at)inquent(dot)com>
Cc: "Christian Fritze" <The(dot)Finn(at)sprawl(dot)de>, "Stephan Szabo" <sszabo(at)megazone23(dot)bigpanda(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: index not used with subselect in where clause ?
Date: 2001-04-17 15:09:22
Message-ID: 23743.987520162@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Rod Taylor" <rod(dot)taylor(at)inquent(dot)com> writes:
> Adding a LIMIT 1 in the subplan may also help -- as you only need a
> single match to make it true so additional finds are useless -- it'll
> stop sooner or will be more likely to use an index than a full table
> scan.

I believe this is not necessary; the WHERE EXISTS(...) context is
sufficient to cue the planner that only one tuple will be retrieved,
and it will alter the subselect's plan accordingly.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-04-17 15:21:22 Re: drastic reduction in speed of inserts as the table grows
Previous Message Tom Lane 2001-04-17 15:04:39 Re: failed sanity check, table answers was not found