>
> One question is how to aggregate ranges that would leave gaps and/or
> overlaps. So in my extension there is a one-param version that forbids
> gaps & overlaps, but I let you permit them by passing extra parameters,
> so the signature is:
>

Perhaps a third way would be to allow and preserve the gaps.

A while back I wrote an extension called disjoint_date_range for storing
sets of dates where it was assumed that most dates would be contiguous. The
basic idea was that The core datatype was an array of ranges of dates, and
with every modification you'd unnest them all to their discrete elements
and use a window function to identify "runs" of dates and recompose them
into a canonical set. It was an efficient way of representing "Every day
last year except for June 2nd and August 4th, when we closed business for
special events."

For arrays of ranges the principle is the same but it'd get a bit more
tricky, you'd have to order by low bound, use window functions to detect
adjacency/overlap to identify your runs, and the generate the canonical
minimum set of ranges in your array.

Reply via email to