pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shatamjeev Dewan <sdewan@nbsps.com>
To: Michael Lewis <mlewis@entrata.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: RE: Declarative Range Partitioning Postgres 11
Date: Fri, 1 Nov 2019 19:26:00 +0000
Message-ID: <F2F23E564EB92A4C80228EB86713BA130BEFA8@TO1RODC.nbspaymentsolutions.com> (raw)
In-Reply-To: <CAHOFxGqZtHphsNbAWJYWpBEyO0oSGuro0zCKWjir+kWbnFv+Aw@mail.gmail.com>
References: <F2F23E564EB92A4C80228EB86713BA130BD969@TO1RODC.nbspaymentsolutions.com>
	<CAHOFxGpDfTH9JqsBirWXCBnGQjmUX-_BbdZi0nKod4HpdCmEEg@mail.gmail.com>
	<F2F23E564EB92A4C80228EB86713BA130BDA8E@TO1RODC.nbspaymentsolutions.com>
	<CAHOFxGqTFO8HRiF5Wng6gLZ6B4hMCEf_HupNmzx=v86yBkijNQ@mail.gmail.com>
	<F2F23E564EB92A4C80228EB86713BA130BEF63@TO1RODC.nbspaymentsolutions.com>
	<CAHOFxGqZtHphsNbAWJYWpBEyO0oSGuro0zCKWjir+kWbnFv+Aw@mail.gmail.com>

Thanks a ton Michael

From: Michael Lewis <mlewis@entrata.com>
Sent: November-01-19 3:20 PM
To: Shatamjeev Dewan <sdewan@nbsps.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Declarative Range Partitioning Postgres 11

On Fri, Nov 1, 2019 at 9:22 AM Shatamjeev Dewan <sdewan@nbsps.com<mailto:sdewan@nbsps.com>> wrote:
Hi Michael,

I want to create a partition by year and subpartition by month in postgres 11 timestamp column. Please advise syntax.


https://www.postgresql.org/docs/11/ddl-partitioning.html

The documentation is rather clear with examples like-

CREATE TABLE measurement_y2006m02 PARTITION OF measurement
    FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE measurement_y2006m03 PARTITION OF measurement
    FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');

Note- Don't partition on function results like date_part because performance will likely suffer greatly. Also note that the top end is always exclusive so the above give a continuous range for those two months.

I would hesitate to partition by more than year alone before upgrading to PG v12. The speed improvements for more than 10-100 partitions (max recommended for PG11) is huge in 12.


view thread (12+ messages)

Message-ID: <F2F23E564EB92A4C80228EB86713BA130BEFA8@TO1RODC.nbspaymentsolutions.com>
Permalink:  ../F2F23E564EB92A4C80228EB86713BA130BEFA8@TO1RODC.nbspaymentsolutions.com/
Also on:    postgresql.org/message-id/F2F23E564EB92A4C80228EB86713BA130BEFA8@TO1RODC.nbspaymentsolutions.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: sdewan@nbsps.com, mlewis@entrata.com
  Subject: Re: Declarative Range Partitioning Postgres 11
  In-Reply-To: <F2F23E564EB92A4C80228EB86713BA130BEFA8@TO1RODC.nbspaymentsolutions.com>
  References: <F2F23E564EB92A4C80228EB86713BA130BD969@TO1RODC.nbspaymentsolutions.com> <CAHOFxGpDfTH9JqsBirWXCBnGQjmUX-_BbdZi0nKod4HpdCmEEg@mail.gmail.com> <F2F23E564EB92A4C80228EB86713BA130BDA8E@TO1RODC.nbspaymentsolutions.com> <CAHOFxGqTFO8HRiF5Wng6gLZ6B4hMCEf_HupNmzx=v86yBkijNQ@mail.gmail.com> <F2F23E564EB92A4C80228EB86713BA130BEF63@TO1RODC.nbspaymentsolutions.com> <CAHOFxGqZtHphsNbAWJYWpBEyO0oSGuro0zCKWjir+kWbnFv+Aw@mail.gmail.com> <F2F23E564EB92A4C80228EB86713BA130BEFA8@TO1RODC.nbspaymentsolutions.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