Re: Auto create partition with declarative partitioning - Mailing list pgsql-admin

From Alvaro Herrera
Subject Re: Auto create partition with declarative partitioning
Date
Msg-id 20181022144939.hpy7zhojvos7j4cr@alvherre.pgsql
Whole thread Raw
In response to Auto create partition with declarative partitioning  (Jorge Torralba <jorge.torralba@gmail.com>)
List 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


pgsql-admin by date:

Previous
From: prasanna rk
Date:
Subject: Re: minimal network speed for replication
Next
From: pavan95
Date:
Subject: Re: Point in time Recovery in Postgres?