Questions tagged [range-types]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
30 votes
5 answers
15k views

Combining separate ranges into largest possible contiguous ranges

I'm trying to combine multiple date ranges (my load is about max 500, most cases 10) that may or may not overlap into the largest possible contiguous date ranges. For example: Data: CREATE TABLE ...
Villiers Strauss's user avatar
1 vote
1 answer
1k views

How to use index for simple time range join?

I have a large (~ 100 million rows) timeseries table t_16 in Postgres 11.5 where the primary key is a field abs_date_time of type timestamp. This is a follow up of this question: Why does a CTE ...
TmTron's user avatar
  • 233
4 votes
1 answer
1k views

Index not used for date range condition

I was querying like this: SELECT count(*) FROM orders WHERE planned_shipping_date >= '2022-04-04' AND planned_shipping_date < '2022-04-05' Then I came across this answer and, because in more ...
AndreKR's user avatar
  • 557
3 votes
1 answer
3k views

Updating table of versioned rows with historical records in PostgreSQL

I have a master table of versioned rows: CREATE TABLE master ( id SERIAL PRIMARY KEY, rec_id integer, val text, valid_on date[], valid_during daterange ); INSERT INTO master (...
danpelota's user avatar
  • 133
2 votes
1 answer
199 views

Ranges over domains do not trigger implicit casting

As far as I was able to find out, it is currently not possible in PostgreSQL v9.5 (and above?) to obtain implicit casting with custom range types. To illustrate, when I define the following demo setup:...
John Frazer's user avatar