Re: Adding per backend commit and rollback counters

Kuba Knysiak <thesniboy@gmail.com>

From: Kuba Knysiak <thesniboy@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: 2026-03-30T20:19:13Z
Lists: pgsql-hackers
Hello,
after reviewing the patch together with Miłosz, we found the following:

- 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).

Also, shouldn't this patch bump catversion? 

Regards,
Kuba

The new status of this patch is: Waiting on Author