Re: Adding per backend commit and rollback counters
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Kuba Knysiak <thesniboy@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2026-03-31T09:24:35Z
Lists: pgsql-hackers
Attachments
Hi, On Mon, Mar 30, 2026 at 08:19:13PM +0000, Kuba Knysiak wrote: > Hello, > after reviewing the patch together with Miłosz, we found the following: Thanks for the review! > - In pgstatfuncs.c, we call pgstat_fetch_stat_backend_by_pid(beentry->st_procpid, NULL) > for each backend row. That path acquires ProcArrayLock via BackendPidGetProc(), > so this repeats lock acquisition for every row. We could simplify this and avoid > taking the lock altogether by fetching directly with > pgstat_fetch_stat_backend(local_beentry->proc_number). Yeah, I think that's a good point. Done that way in the attached. Also adding a check on the backend type as it was done in pgstat_fetch_stat_backend_by_pid(). > Also, shouldn't this patch bump catversion? Yes and that was mentioned in the 0003 commit message. We usually don't change it in the patch itself (could easily produce rebase noise) but just put an XXX in the commit message so that it's not forgoten when pushed. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com