pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: Kevin Way <kevin.way@overtone.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: aggregate functions, COUNT
Date: Tue, 02 Oct 2001 13:59:26 -0400
Message-ID: <10539.1002045566@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.21.0110020944100.46517-100000@megazone23.bigpanda.com>
References: <Pine.BSF.4.21.0110020944100.46517-100000@megazone23.bigpanda.com>

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.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <10539.1002045566@sss.pgh.pa.us>
Permalink:  ../10539.1002045566@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10539.1002045566@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, sszabo@megazone23.bigpanda.com, kevin.way@overtone.org
  Subject: Re: aggregate functions, COUNT
  In-Reply-To: <10539.1002045566@sss.pgh.pa.us>

* 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