On Fri, Jan 15, 2021 at 07:07:44PM -0300, Alvaro Herrera wrote: > I wrote this patch last year in response to a customer issue and I > thought I had submitted it here, but evidently I didn't. So here it is. > > The short story is: in commit 5364b357fb11 we increased the size of > pg_commit (née pg_clog) but we didn't increase the size of pg_commit_ts > to match. When commit_ts is in use, this can lead to significant buffer > thrashing and thus poor performance. > > Since commit_ts entries are larger than pg_commit, my proposed patch uses > twice as many buffers.
This is a step in the right direction. With commit_ts entries being forty times as large as pg_xact, it's not self-evident that just twice as many buffers is appropriate. Did you try other numbers? I'm fine with proceeding even if not, but the comment should then admit that the new number was a guess that solved problems for one site. > --- a/src/backend/access/transam/commit_ts.c > +++ b/src/backend/access/transam/commit_ts.c > @@ -530,7 +530,7 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS) The comment right above here is outdated. > Size > CommitTsShmemBuffers(void) > { > - return Min(16, Max(4, NBuffers / 1024)); > + return Min(256, Max(4, NBuffers / 512)); > } > > /*