From: | Thomas Kellerer <shammat(at)gmx(dot)net> |
---|---|
To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Suggestion: provide a "TRUNCATE PARTITION" command |
Date: | 2021-01-08 09:36:15 |
Message-ID: | 99277f39-f1a1-6da5-176c-3def058cf568@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 than doing 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 name might 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 running DELETE) could be used to identify the target partitions and then this list would be used to TRUNCATE all resulting partitions.
What does the community think about this?
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Tim.Colles | 2021-01-08 10:06:32 | Re: How to keep format of views source code as entered? |
Previous Message | 徐閔翊 Jordy Hsu | 2021-01-08 09:07:00 | Coding question |