pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Jeremy Finzel <finzelj@gmail.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Partitioning with range types
Date: Fri, 15 Jun 2018 09:23:07 -0700
Message-ID: <5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com> (raw)
In-Reply-To: <CAMa1XUiHj4-okAcKJYG3R-nFeP3WB9hL+todwjtgpm7swXmkNg@mail.gmail.com>
References: <CAMa1XUiHj4-okAcKJYG3R-nFeP3WB9hL+todwjtgpm7swXmkNg@mail.gmail.com>

On 06/15/2018 08:26 AM, Jeremy Finzel wrote:
> Several months ago we had some detailed discussions about whether to use 
> separate date columns to indicate a date range, or to use the daterange 
> data type.  We opted for the latter because this type is specifically 
> designed for this use case - a table that has a range of valid dates for 
> the data it contains.  It also has some great operators and functions.
> 
> But I recently discovered that daterange is not supported in any way as 
> a partition key because it depends on an expression.  I was excited 

A quick test:

Postgres 10.4

create table dr_partition(id integer, dr daterange) PARTITION BY LIST(dr);

  \d dr_partition
              Table "public.dr_partition"
  Column |   Type    | Collation | Nullable | Default
--------+-----------+-----------+----------+---------
  id     | integer   |           |          |
  dr     | daterange |           |          |
Partition key: LIST (dr)


create table dr_1 PARTITION OF dr_partition FOR VALUES IN ('[06/01/2018, 
06/30/2018]');

\d dr_1
                  Table "public.dr_1"
  Column |   Type    | Collation | Nullable | Default
--------+-----------+-----------+----------+---------
  id     | integer   |           |          |
  dr     | daterange |           |          |
Partition of: dr_partition FOR VALUES IN ('[2018-06-01,2018-07-01)')


> about this possibility in pg11 with unique constraints on the parent 
> table, but now it appears it may have instead been to our advantage if 
> we had two separate date columns instead, so that we could use UPSERT 
> transparently for date-ranged tables.
> 
> Is there any possibility of this feature coming for range types, or, if 
> we really want to partition using daterange, should we look instead at 
> two separate date columns?
> 
> Thanks,
> Jeremy


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (4+ messages)  latest in thread

Message-ID: <5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com>
Permalink:  ../5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com/
Also on:    postgresql.org/message-id/5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, finzelj@gmail.com
  Subject: Re: Partitioning with range types
  In-Reply-To: <5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com>
  References: <CAMa1XUiHj4-okAcKJYG3R-nFeP3WB9hL+todwjtgpm7swXmkNg@mail.gmail.com> <5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox