Suggestion: provide a "TRUNCATE PARTITION" command

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Suggestion: provide a "TRUNCATE PARTITION" command
Дата
Msg-id 99277f39-f1a1-6da5-176c-3def058cf568@gmx.net
обсуждение исходный текст
Ответы Re: Suggestion: provide a "TRUNCATE PARTITION" command  (legrand legrand <legrand_legrand@hotmail.com>)
Re: Suggestion: provide a "TRUNCATE PARTITION" command  (Michael Lewis <mlewis@entrata.com>)
Список pgsql-general
Hello,

I wonder if it made sense to add a "TRUNCATE PARTITION" command to Postgres?

Especially during bulk loads it's more efficient to TRUNCATE a partition if I know I want to replace all rows, rather
thandoing a DELETE.
 

Currently this requires dynamic SQL which isn't always feasible (and might get complicated quickly).

So I was thinking that a new command to allow truncating partitions by identifying the partitions by "value" rather by
namemight be helpful in that case.
 

Something along the lines of:

     truncate partitions of base_table
     for values in (...);

If the IN part allowed for sub-queries then this could be used to gather the partition keys from e.g. a staging table.
In my naive understanding, I would think the current partition pruning code (e.g. that picks the partitions when
runningDELETE) could be used to identify the target partitions and then this list would be used to TRUNCATE all
resultingpartitions.
 

What does the community think about this?

Thomas



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

Предыдущее
От: 徐閔翊 Jordy Hsu
Дата:
Сообщение: Coding question
Следующее
От: Tim.Colles@ed.ac.uk
Дата:
Сообщение: Re: How to keep format of views source code as entered?