i keep track of roads that a person has biked/walked for Wandrer (wandrer.earth), and storing everything as a geometry would be a storage and analytical nightmare. keeping things as a range lets you easily determine what part of an activity covered new ground, and you can generate the geometry / length on demand while only storing a few integers (plus the raw road geometry, but that's shared among everyone).
src: https://github.com/postgres/postgres/blob/f14aad5169baa5e2ac...
We've loosely landed at just materializing the dataset into another table by calling `unnest` in a trigger and then using an index on that table.
Multiranges could be used to further optimise for storage of duplicate data (if a data pattern repeats at different intervals) but it's not a big enough margin for me yet.
The reason I'm curious is because may future SQL database implementations will most likely use the standard at least in some capacity, so it'd be nice to know, how future-proof and DBMS-switch-proof a schema using these could be.
[1]: https://www.postgresql.org/docs/current/rangetypes.html
[2]: https://www.postgresql.org/docs/current/features-sql-standar...
(The word ‘range’ appears once there, in “F404. Range variable for common column names”, but reading the English parts of https://github.com/dazuiba008/digoal_blog_fork/blob/master/2..., it’s clear that isn’t about range types)
There was a website comparing the major RDBMSs to the standard with examples. I can not find it now but I found this:
https://en.wikipedia.org/wiki/SQL_compliance
Edit: this was it https://troels.arvin.dk/db/rdbms/
It's not updated though.
Arguably, timestamp with timezone should store a timestamp plus a tz_database time zone. Storing offsets is easy and useful but not necessarily correct. Timestamp with Offset should be a different type.
Validating all of those rules would be a hairy mess. For example, what do you do with a timestamp in the future when changes are introduced (negative leap seconds, changes to DST, geopolitical changes affecting timezones).
That's only a tiny thing, though. I'm sure there is more. I don't use Microsoft SQL Server. Quite happy with PostgreSQL (and SQLite for tiny in file things).
The coolest application of multiranges I've heard about is for astronomical observations. The authors of this paper were kind enough to share an early draft with me, and they say it greatly speeds up comparisons of sky objects. It's very accessible and a fun read:
> The array containment operators (<@ and @>) [...]
What's the performance like to get multiranges from a million row column of unique integers, that has a few gaps in it.
(Also slightly unsorted, but obv can do that in query).