CREATE DATABASE ... STRATEGY WAL_LOG issues

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org, Dilip Kumar <dilipbalaut@gmail.com>, Robert Haas <robertmhaas@gmail.com>
Date: 2023-03-21T07:01:13Z
Lists: pgsql-hackers
Hi,

While hacking on my relation extension patch I found two issues with WAL_LOG:

1) RelationCopyStorageUsingBuffer() doesn't free the used strategies. This
   means we'll use #relations * ~10k memory

2) RelationCopyStorageUsingBuffer() gets the buffer for the target relation
   with RBM_NORMAL, therefore requiring a read of a block guaranteed to be
   zero

Easy enough to fix and shows clear improvement. One thing I wonder is if it's
worth moving the strategies up one level? Probaly not, but ...

Greetings,

Andres Freund



Commits

  1. Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY WAL_LOG