Re: Extending range type operators to cope with elements

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Esteban Zimanyi <ezimanyi(at)ulb(dot)ac(dot)be>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Extending range type operators to cope with elements
Date: 2019-09-14 22:35:52
Message-ID: CADkLM=d1PX7XzzXvXVXCdv7enN-H8h_hpwGU0UMeB_gHsnaFxw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
>
> >- @> contains range/element
> >- <@ element/range is contained by
>

I'm not a heavy user or range types, so I can't really judge how useful
> that is in practice, but it seems like a fairly natural extension of the
> existing operators. I mean, if I understand it correctly, the proposed
> behavior is equal to treating the element as a "collapsed range".
>

I used to give a talk on ranges and partitioning, prior to postgresql
getting native partitioning (see:
https://wiki.postgresql.org/images/1/1b/Ranges%2C_Partitioning_and_Limitations.pdf
)
In that talk, I mention the need for exactly these operators, specifically
for an extension called range_partitioning which had some logic for "If I
were to insert a row with this value, what partition would it end up in?"
which allowed for a subsequent COPY operation directly to that partition.
That logic essentially binary-searched a series of ranges, so it needed an
"elem <@ range" as well as << and >>.

Yes, constructing a collapsed range was the work-around I used in the
absence of real functions.

That extension has been replaced by real table partitioning and the planner
itself now does similar logic for partition pruning.

So yes, I've had a need for those operators in the past. What I don't know
is whether adding these functions will be worth the catalog clutter.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2019-09-14 23:00:54 Re: pg_rewind docs correction
Previous Message Tomas Vondra 2019-09-14 21:09:10 Re: Extending range type operators to cope with elements