Re: LIMIT 1 == EXISTS optimization?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Rowell <richard(dot)rowell(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: LIMIT 1 == EXISTS optimization?
Date: 2009-10-02 18:38:18
Message-ID: 9560.1254508698@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Richard Rowell <richard(dot)rowell(at)gmail(dot)com> writes:
> I'm no backend guru, so I was hoping someone could explain what the original
> query-plan was doing. If all you need to know is if a row exists, why loop
> over all 3M rows? It seems very simplistic to assume the a LIMIT 1 clause
> on the end of all EXISTS subqueries would be a general case optimization...

[ squint... ] It should be assuming that already.

It looks like your case might have something to do with using or not
using a partial index. Can you extract a reproducible test case?
And what PG version is this exactly?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2009-10-02 18:42:56 Re: latest hstore patch
Previous Message Alvaro Herrera 2009-10-02 18:16:03 remove useless set of active snap