Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

Поиск
Список
Период
Сортировка
От Dmitry Koval
Тема Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Дата
Msg-id 277c8df2-ce99-36b6-817a-ed510c7e8b82@postgrespro.ru
обсуждение исходный текст
Ответ на Re: Add SPLIT PARTITION/MERGE PARTITIONS commands  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Add SPLIT PARTITION/MERGE PARTITIONS commands  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Thanks for comments and advice!
I thought about this problem and discussed about it with colleagues.
Unfortunately, I don't know of a good general solution.

19.09.2022 22:56, Robert Haas пишет:
> If you know that a certain partition is not changing, and you would
> like to split it, you can create two or more new standalone tables and
> populate them from the original partition using INSERT .. SELECT. Then
> you can BEGIN a transaction, DETACH the existing partitions, and
> ATTACH the replacement ones. By doing this, you take an ACCESS
> EXCLUSIVE lock on the partitioned table only for a brief period. The
> same kind of idea can be used to merge partitions.

But for specific situation like this (certain partition is not changing) 
we can add CONCURRENTLY modifier.
Our DDL query can be like

ALTER TABLE...SPLIT PARTITION [CONCURRENTLY];

With CONCURRENTLY modifier we can lock partitioned table in 
ShareUpdateExclusiveLock mode and split partition - in 
AccessExclusiveLock mode. So we don't lock partitioned table in 
AccessExclusiveLock mode and can modify other partitions during SPLIT 
operation (except split partition).
If smb try to modify split partition, he will receive error "relation 
does not exist" at end of operation (because split partition will be drop).


-- 
With best regards,
Dmitry Koval

Postgres Professional: http://postgrespro.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Fix typos in code comments
Следующее
От: "Jonathan S. Katz"
Дата:
Сообщение: Re: why can't a table be part of the same publication as its schema