Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f92Hxrn24109 for ; Tue, 2 Oct 2001 13:59:53 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f92HxQI10542; Tue, 2 Oct 2001 13:59:26 -0400 (EDT) To: Stephan Szabo cc: Kevin Way , pgsql-sql@postgresql.org Subject: Re: aggregate functions, COUNT In-reply-to: References: Comments: In-reply-to Stephan Szabo message dated "Tue, 02 Oct 2001 09:47:00 -0700" Date: Tue, 02 Oct 2001 13:59:26 -0400 Message-ID: <10539.1002045566@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200110/26 X-Sequence-Number: 4981 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. regards, tom lane