Re: range_agg - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: range_agg
Date
Msg-id CADkLM=dP8f8T0oDxOsYWDacZO9ydj3o5xgr7aTvhZgQWonm3Bw@mail.gmail.com
Whole thread Raw
In response to range_agg  (Paul Jungwirth <pj@illuminatedcomputing.com>)
Responses Re: range_agg
List pgsql-hackers
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.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Commits 8de72b and 5457a1 (COPY FREEZE)
Next
From: Peter Geoghegan
Date:
Subject: Re: VACUUM can finish an interrupted nbtree page split -- is that okay?