Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7332E4769CE for ; Wed, 30 Oct 2002 11:25:55 -0500 (EST) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id E42AD4768EF for ; Wed, 30 Oct 2002 11:25:53 -0500 (EST) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id LAA00836; Wed, 30 Oct 2002 11:25:56 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma000834; Wed, 30 Oct 02 11:25:43 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id LAA18420; Wed, 30 Oct 2002 11:25:03 -0500 Message-ID: <3DC00823.7396E79C@nsd.ca> Date: Wed, 30 Oct 2002 11:26:11 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: Josh Berkus Cc: Tom Lane , pgsql-sql@postgresql.org Subject: Re: BOOLEAN question References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/407 X-Sequence-Number: 10124 Why not simply: SELECT COALESCE( (SELECT true FROM ... WHERE boolcol LIMIT 1), FALSE); JLL Josh Berkus wrote: > > Tom, > > > Perhaps > > SELECT true = ANY (SELECT boolcol FROM ...); > > or > > SELECT true IN (SELECT boolcol FROM ...); > > > > Which is not to say that MAX(bool) might not be a nicer solution; > > but you can definitely do it with SQL-spec constructs. > > Based on some rough testing, > > SELECT true = ANY ( SELECT boolcol FROM complex query ) > > Is marginlly faster than > > SELECT max(boolcol) FROM complex query > > With a custom MAX(boolean) function. > > So I'll stick to ANY(). > > -Josh > > ______AGLIO DATABASE SOLUTIONS___________________________ > Josh Berkus > Complete information technology josh@agliodbs.com > and data management solutions (415) 565-7293 > for law firms, small businesses fax 621-2533 > and non-profit organizations. San Francisco > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org