Re:Multiranges in Postgres
by timwis on Thursday October 27, 2022 @03:13AM
(#33354245)
Wow, I was just trying to solve the problem of merging overlapping periods in ruby. Life would be so much easier if the database did it for me!
[ Parent
| on HN ]
wow
oh
[dead]
Test failed
It works!
Sort by lowest start, merge left when they overlap. Emit current span if not. Repeat.
Re:Multiranges in Postgres
by badelectron on Saturday October 29, 2022 @07:04AM
(#33382939)
If you want to do this with a data structure instead of a database then discrete interval encoding trees solve this problem well. https://xlinux.nist.gov/dads/HTML/discretintrv.html