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
