Re: aggregate functions, COUNT - Mailing list pgsql-sql

From Kevin Way
Subject Re: aggregate functions, COUNT
Date
Msg-id 20011003025441.C36630@bean.overtone.org
Whole thread Raw
In response to Re: aggregate functions, COUNT  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
* Tom Lane <tgl@sss.pgh.pa.us> [02-10-01 18:02]:
> Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> > I think you could use EXISTS for that,
> > select EXISTS (<query>); should give a true/false on whether the 
> > query returned any rows.  I'm not sure if it stops after one row
> > or not, but if it doesn't you can add a limit 1 to the query.
> 
> Yes it does stop after one row; and furthermore, the planner knows to
> generate a fast-start plan for it.  (Or at least it's supposed to
> ... hmm, this seems to be broken in current sources ...)  Anyway,
> there's no need for LIMIT 1 inside an EXISTS, because the planner
> assumes that automatically.

Thank you muchly, I did some profiling and SELECT EXISTS is indeed
exactly what I wanted.  
       -Kevin Way

-- 
Kevin Way <kevin.way@overtone.org>
http://www.overtone.org/


pgsql-sql by date:

Previous
From: Barry Lind
Date:
Subject: Re: jdbc driver
Next
From: Jeong Jaeick, 정재익
Date:
Subject: Re: Question about indexing!