pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Way <kevin.way@overtone.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: aggregate functions, COUNT
Date: Wed, 3 Oct 2001 02:54:41 +0000
Message-ID: <20011003025441.C36630@bean.overtone.org> (raw)
In-Reply-To: <10539.1002045566@sss.pgh.pa.us>
References: <Pine.BSF.4.21.0110020944100.46517-100000@megazone23.bigpanda.com>
	<10539.1002045566@sss.pgh.pa.us>

* 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/



view thread (4+ messages)

Message-ID: <20011003025441.C36630@bean.overtone.org>
Permalink:  ../20011003025441.C36630@bean.overtone.org/
Also on:    postgresql.org/message-id/20011003025441.C36630@bean.overtone.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: kevin.way@overtone.org, tgl@sss.pgh.pa.us
  Subject: Re: aggregate functions, COUNT
  In-Reply-To: <20011003025441.C36630@bean.overtone.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox