On Fri, Jan 17, 2020 at 3:03 PM Ken Benson <Ken@xxxxxxxxxxxxx> wrote:
So – I THINK I know – that when a row is deleted from a table – the row is not actually removed from the table – but, merely marked as deleted, thus becoming a dead tuple.
AUTOVACUUM – takes care of the process of removing these dead tuples.
My question. If – an insert occurs to that same table before autovacuum comes along, does that inserted record use a dead tuple? Or – does the insert result in an actual added row?
There is a double indirection. The index entries point to a specific "line item" within a specific table block. In that table block, that line item points to an area in that same block for the actual row data.
Once a row has been delete long enough that no currently active snapshot can possibly care about it, anyone can "clean up" the table block so that the "line item" has a flag set to indicate it no longer points to any storage within the block, and that former storage for the row is then available for reuse. But only a vacuum can make the line item itself available for reuse.
Now if someone other than a vacuum has cleaned up a block, will it advertise the reclaimed space in the freespace map, so that an INSERT can easily find it? I don't know.
Cheers,
Jeff