Re: Adding support for Default partition in partitioning

From: Rahila Syed <rahilasyed90(at)gmail(dot)com>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, Keith Fiske <keith(at)omniti(dot)com>, David Steele <david(at)pgmasters(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adding support for Default partition in partitioning
Date: 2017-04-05 09:57:11
Message-ID: CAH2L28vFxEN36qaPa2t1XfFRX7Jf-M-wQXrTFpJiAc1Z5-q9Gw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Amit,

>Could you briefly elaborate why you think the lack global index support
>would be a problem in this regard?
I think following can happen if we allow rows satisfying the new partition
to lie around in the
default partition until background process moves it.
Consider a scenario where partition key is a primary key and the data in
the default partition is
not yet moved into the newly added partition. If now, new data is added
into the new partition
which also exists(same key) in default partition there will be data
duplication. If now
we scan the partitioned table for that key(from both the default and new
partition as we
have not moved the rows) it will fetch the both rows.
Unless we have global indexes for partitioned tables, there is chance of
data duplication between
child table added after default partition and the default partition.

>Scanning it and moving rows to the newly added partition while holding an
>AccessExclusiveLock on the parent will block any and all of the concurrent
>activity on it until the row-movement is finished.
Can you explain why this will require AccessExclusiveLock on parent and
not just the default partition and newly added partition?

Thank you,
Rahila Syed

On Wed, Apr 5, 2017 at 1:22 PM, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
wrote:

> On 2017/04/05 14:41, Rushabh Lathia wrote:
> > I agree about the future plan about the row movement, how that is I am
> > not quite sure at this stage.
> >
> > I was thinking that CREATE new partition is the DDL command, so even
> > if row-movement works with holding the lock on the new partition table,
> > that should be fine. I am not quire sure, why row movement should be
> > happen in the back-ground process.
>
> I think to improve the availability of access to the partitioned table.
>
> Consider that the default partition may have gotten pretty large.
> Scanning it and moving rows to the newly added partition while holding an
> AccessExclusiveLock on the parent will block any and all of the concurrent
> activity on it until the row-movement is finished. One may be prepared to
> pay this cost, for which there should definitely be an option to perform
> the row-movement in the same transaction (also possibly the default
> behavior).
>
> Thanks,
> Amit
>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Beena Emerson 2017-04-05 10:04:25 Re: increasing the default WAL segment size
Previous Message Amit Langote 2017-04-05 09:54:46 Re: UPDATE of partition key