Re: unique index for periods - Mailing list pgsql-general

From Tom Lane
Subject Re: unique index for periods
Date
Msg-id 15363.1250784595@sss.pgh.pa.us
Whole thread Raw
In response to Re: unique index for periods  (Greg Stark <gsstark@mit.edu>)
List pgsql-general
Greg Stark <gsstark@mit.edu> writes:
> On Thu, Aug 20, 2009 at 3:14 PM, Tom Lane<tgl@sss.pgh.pa.us> wrote:
>> I don't believe it is possible to use a btree index for this purpose,
>> because there just isn't a way to express "overlaps" as a total order.

> That's true for the general case of indexing ranges but I don't think
> that's true for the case where overlaps are illegal.

Uh, no, the question is not about whether there are expected to be any
overlapping entries in the index.  The point is that "overlaps" simply
does not fit the semantic model of a btree-processable equality
relationship.

> In such a case
> you could just, sorting by the start point, compare the previous
> entry's end point with your start point and the next entry with your
> end point.

Even if you hacked the code to work like that, it'll fail completely for
deferred unique constraints, not to mention deleted entries that haven't
yet been purged from the index.

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Temp table or normal table for performance?
Next
From: Christof König
Date:
Subject: German ispell dictionary: error parsing affix file