Re: Combine Prune and Freeze records emitted by vacuum

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Melanie Plageman <melanieplageman@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>, Peter Geoghegan <pg@bowt.ie>
Date: 2024-04-01T21:57:27Z
Lists: pgsql-hackers
On 01/04/2024 20:22, Melanie Plageman wrote:
>>  From 17e183835a968e81daf7b74a4164b243e2de35aa Mon Sep 17 00:00:00 2001
>> From: Melanie Plageman <melanieplageman@gmail.com>
>> Date: Fri, 29 Mar 2024 19:43:09 -0400
>> Subject: [PATCH v11 3/7] Introduce PRUNE_DO_* actions
>>
>> We will eventually take additional actions in heap_page_prune() at the
>> discretion of the caller. For now, introduce these PRUNE_DO_* macros and
>> turn mark_unused_now, a paramter to heap_page_prune(), into a PRUNE_DO_
> 
> paramter -> parameter
> 
>> action.
>> ---
>>   src/backend/access/heap/pruneheap.c  | 51 ++++++++++++++--------------
>>   src/backend/access/heap/vacuumlazy.c | 11 ++++--
>>   src/include/access/heapam.h          | 13 ++++++-
>>   3 files changed, 46 insertions(+), 29 deletions(-)
>>
>> diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
>> index fb0ad834f1b..30965c3c5a1 100644
>> --- a/src/backend/access/heap/pruneheap.c
>> +++ b/src/backend/access/heap/pruneheap.c
>> @@ -29,10 +29,11 @@
>>   /* Working data for heap_page_prune and subroutines */
>>   typedef struct
>>   {
>> +	/* PRUNE_DO_* arguments */
>> +	uint8		actions;
> 
> I wasn't sure if actions is a good name. What do you think?

Committed this part, with the name 'options'. There's some precedent for 
that in heap_insert().

I decided to keep it a separate bool field here in the PruneState 
struct, though, and only changed it in the heap_page_prune() function 
signature. It didn't feel worth the code churn here, and 
'prstate.mark_unused_now' is a shorter than "(prstate.options & 
HEAP_PRUNE_PAGE_MARK_UNUSED_NOW) != 0" anyway.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




Commits

  1. Combine freezing and pruning steps in VACUUM

  2. Refactor how heap_prune_chain() updates prunable_xid

  3. Introduce 'options' argument to heap_page_prune()

  4. Handle non-chain tuples outside of heap_prune_chain()

  5. Refactor heap_prune_chain()

  6. Minor refactoring in heap_page_prune

  7. Remove obsolete comment about VACUUM retrying pruning

  8. Merge prune, freeze and vacuum WAL record formats

  9. Remove unused PruneState member rel

  10. Reorganize heap_page_prune() function comment