Received: from femail21.sdc1.sfba.home.com (femail21.sdc1.sfba.home.com [24.0.95.146]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f932tdn77037 for ; Tue, 2 Oct 2001 22:55:39 -0400 (EDT) (envelope-from kway@overtone.org) Received: from bean.overtone.org ([24.249.254.100]) by femail21.sdc1.sfba.home.com (InterMail vM.4.01.03.20 201-229-121-120-20010223) with ESMTP id <20011003025534.UYOS25011.femail21.sdc1.sfba.home.com@bean.overtone.org> for ; Tue, 2 Oct 2001 19:55:34 -0700 Received: by bean.overtone.org (Postfix, from userid 1001) id A83F05B48A; Wed, 3 Oct 2001 02:55:33 +0000 (GMT) Date: Wed, 3 Oct 2001 02:54:41 +0000 From: Kevin Way To: Tom Lane Subject: Re: aggregate functions, COUNT Message-ID: <20011003025441.C36630@bean.overtone.org> References: <10539.1002045566@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <10539.1002045566@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Tue, Oct 02, 2001 at 01:59:26PM -0400 Resent-From: kway@bean.overtone.org Resent-Date: Wed, 3 Oct 2001 02:55:33 +0000 Resent-To: pgsql-sql@postgresql.org Resent-Message-Id: <20011003025533.A83F05B48A@bean.overtone.org> X-Archive-Number: 200110/29 X-Sequence-Number: 4984 * Tom Lane [02-10-01 18:02]: > Stephan Szabo writes: > > I think you could use EXISTS for that, > > select EXISTS (); 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 http://www.overtone.org/