here's what you can do at run-time these days:
set commit_delay to 1000 : wait for 1000ms before calling fsync just in case someone else commits in that time & we can fsync together
set commit_siblings to 1 : but only if at least 1 other transaction is processing (you can't set this to 0)
so - to enforce at least one other transaction to be running, I put the whole darn thing back inside the db_foreach and wrapped the whole shebang inside a db_transaction.
I put the set commands inside the db_foreach to make sure they hit the right db connection pool/session
then i need to restore the previous values because they are remembered across sessions and i like to sleep at night.
i would rather do this in a dedicated pool, but it's a lot of overhead keeping a pool arount to be used once a month. let's hope we don't crash. or if we do, nothing important should be using the second pool...