Auto create partition with declarative partitioning

From: Jorge Torralba <jorge(dot)torralba(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Auto create partition with declarative partitioning
Date: 2018-10-19 20:52:48
Message-ID: CACut7uSQhKPusp8Cvx-dK3huwZrRQw=aER23xs9U4fxS8-wvDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Trying to make this work but am having difficulties.

I have created a table with a timestamp column that i wish to partition by
range using the timestamp column.

My objective is to test if a partition exists for the date range and create
it if it does not.

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.

Therefore I cannot call the function to check if the partition exists.

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

--
Thanks,

Jorge Torralba
----------------------------

Note: This communication may contain privileged or other confidential
information. If you are not the intended recipient, please do not print,
copy, retransmit, disseminate or otherwise use the information. Please
indicate to the sender that you have received this email in error and
delete the copy you received. Thank You.

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2018-10-19 20:57:43 Re: Auto create partition with declarative partitioning
Previous Message prasanna rk 2018-10-19 13:11:56 Re: minimal network speed for replication