Batch upserts in child tables of a partition set created using pg partman

Specify an action for ON CONFLICT while creating partition set

select partman.create_parent(p_parent_table := 'public.users', 
p_control := 'created_at',
p_type := 'partman',
p_interval := 'daily',
p_automatic_maintenance := 'on',
p_upsert := 'ON CONFLICT (id) DO UPDATE SET email = EXCLUDED.email, last_name = EXCLUDED.last_name, updated_at = EXCLUDED.updated_at',
p_debug := TRUE);

Insert statement that will cause violation error

insert into users 
(id, first_name, last_name, email, created_at, updated_at)
values (1, 'foo', 'bar', 'foo@exmplae.com', now(), now()),
(2, 'abc', 'pqr', 'abc@example.com', now(), now());

--

--

--

Product Engineer at Gojek.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Asheet Bhaskar

Asheet Bhaskar

Product Engineer at Gojek.

More from Medium

Authentication Failure Error in wlsdm.log File

Multi-Raft — Increase up create a performance for Apache Hadoop-Ozone.

How to Clear Confluent Certified Developer for Apache Kafka

CS371p Spring 2022 Blog # 7: Jeffrey Liu