Re: Range Types: empty ranges - Mailing list pgsql-hackers

From Nathan Boley
Subject Re: Range Types: empty ranges
Date
Msg-id AANLkTi=7anH8b111-aGkdzEYiBf1MK_74Ly1r29GvVwd@mail.gmail.com
Whole thread Raw
In response to Re: Range Types: empty ranges  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
FWIW, a very informal survey of probabilists didn't yield any reason
for trying to put an order on the empty set ( unless the metric was
cardinality or other equivalence relation ).

I think the problem here is that the idea of union and intersection
forming a ring over sets is being conflated with the order relation.
Clearly, combining the two notions can be inconsistent.  However...

>> >  A UNION (B INTERSECT C) = (A UNION B) INTERSECT (A UNION C)
>>
>> But the basic range type isn't even closed under UNION.
>
> An excellent point. Allow me to move the target a little:
>
>  WHERE A && B AND A && C
> and:
>  WHERE A && (B INTERSECT C)
>
> That seems like a logically sound transformation, but if (B INTERSECT C)
> is empty, it relies on the empty range for those two to be equivalent.
>
> Now, I agree that lack of closure on UNION exhibits many of the problems
> that I am pointing out related to forbidding empty ranges. However, I'm
> not sure if that means we should give up on either.

This seems potentially very useful, because we can transform WHERE A
&& B AND A && C from a bitmap scan into WHERE A && (B INTERSECT C), a
simple index scan. In the union case ( even if we had a type that
supported disjoint intervals), I doubt we would ever make that
transformation because the index will probably still be over connected
intervals.

So, +1 for keeping it how it is ( but maybe with a better error message ).

Best,
Nathan


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: psql patch: tab-complete :variables also at buffer start
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Debian readline/libedit breakage