pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: BOOLEAN question
Date: Tue, 29 Oct 2002 20:22:00 -0600
Message-ID: <20021030022200.GB32582@wolff.to> (raw)
In-Reply-To: <Pine.LNX.4.44.0210291849280.2006-100000@localhost.localdomain>
References: <200210281729.35967.josh@agliodbs.com>
	<Pine.LNX.4.44.0210291849280.2006-100000@localhost.localdomain>

On Tue, Oct 29, 2002 at 23:19:55 +0100,
  Peter Eisentraut <peter_e@gmx.net> wrote:
> Josh Berkus writes:
> 
> > I wrote a MAX(bool), what are the chances it would get added to the core?   I
> > don't see any good reason not to have one.
> 
> One reason not to have one is that Boolean values are not naturally
> ordered, so a maximum doesn't exist.  (Yes, I know there are comparison
> operators defined for boolean, but that doesn't make it right.)
> 
> What seems more reasonable is to define conjuntion and disjunction
> aggregates, which would mostly do the same thing but their semantics
> wouldn't be as controversial.

However they would be slow. If you use an aggregate you don't get to short
circuit the calculation. And for even distributed true and false values,
most of the time the aggregate result would be known after just a few rows
were checked.

When checking for such values in long lived tables where one of the values
occurs seldomly, using a partial index and a select could be a big win.
I don't think this will work in the case that started this thread since
it postulated checking the output of a complex query. However even in
this case it may be worthwhile to rewrite the query as an exists test
for boolcol to be the short circuit value so that the complex query
need not be fully calculated.



view thread (10+ messages)  latest in thread

Message-ID: <20021030022200.GB32582@wolff.to>
Permalink:  ../20021030022200.GB32582@wolff.to/
Also on:    postgresql.org/message-id/20021030022200.GB32582@wolff.to

 · 

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: bruno@wolff.to, peter_e@gmx.net, josh@agliodbs.com, sszabo@megazone23.bigpanda.com
  Subject: Re: BOOLEAN question
  In-Reply-To: <20021030022200.GB32582@wolff.to>

* 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