I wrote:
> Hmm ... also check commit status (pg_clog access). I've always thought
> that those things couldn't be done in bgwriter, because it wasn't
> running real transactions, but right at the moment I can't see that
> there is any obstacle. Perhaps that meme dates from a time when
> GetOldestXmin didn't work outside a transaction?
On further thought, I think what I'm remembering is that full-scale
VACUUM can't work inside bgwriter, because you need to take table-level
locks and worry about index vs heap consistency. But as long as HOT
pruning involves only a single heap page I see no need for it to take
more than the buffer-level locks on that page.
regards, tom lane