On Tue, Oct 29, 2002 at 23:19:55 +0100,
  Peter Eisentraut <[EMAIL PROTECTED]> 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.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply via email to