Re: Transaction locks on first insert into partitioned table partition

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Martin Lund Askøe <martinlundaskoe(at)gmail(dot)com>
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: Transaction locks on first insert into partitioned table partition
Date: 2019-06-08 06:49:18
Message-ID: CAKJS1f-V+4qStAf2kT37zPo58ESAFJV0GZCLW6GPoYc4OU7E3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, 7 Jun 2019 at 19:06, Martin Lund Askøe
<martinlundaskoe(at)gmail(dot)com> wrote:
> Do you know if there is any way to force update the relcache entry during my 'attach'-transaction?

You could just do a dummy insert after the ATTACH PARTITION
transaction ends and before the transaction where you start inserting
the data. Something like:

insert into partition_table_2019_01_01 (id, some_info, e_timestamp)
select 1,'',now() where 1=0;

That'll build and cache the partition bound in the partitions relcache entry.

I'm curious to know why you have concerns about the AccessShareLock on
the partitioned table being held during the insert. Can you explain
that?

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Martin Lund Askøe 2019-06-08 20:30:29 Re: Transaction locks on first insert into partitioned table partition
Previous Message Martin Lund Askøe 2019-06-07 07:05:25 Re: Transaction locks on first insert into partitioned table partition