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