Re: Auto create partition with declarative partitioning

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Jorge Torralba <jorge(dot)torralba(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Auto create partition with declarative partitioning
Date: 2018-10-22 14:49:39
Message-ID: 20181022144939.hpy7zhojvos7j4cr@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 2018-Oct-19, Jorge Torralba wrote:

> In the past I have had a before insert trigger which I would send to a
> create partition function. Extract the info from NEW.createdate, and use
> some logic to create the partition if it did not exists for the create date.
>
> However, now, with the partition by range, I get the error :
>
> Partitioned tables cannot have BEFORE / FOR EACH ROW triggers.

Interesting. I don't think this was ever mentioned as a possible use
case for BEFORE triggers on partitioned tables, during the pg11
development. Basically we forbade BEFORE triggers on partitioned
tables. (You can find the reasons for that in the thread that discussed
row trigger development).

> Other than creating a bunch of partitions in advance, what are my options?

Create *one* partition in advance?

Another option would be to contribute the feature of automatically
creating the partitions for Postgres 12 :-)

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message pavan95 2018-10-23 04:43:55 Re: Point in time Recovery in Postgres?
Previous Message prasanna rk 2018-10-22 14:12:59 Re: minimal network speed for replication