Rethink prior patch to filter out dead backend entries from the pgstats
file. The original code probed the PGPROC array separately for each PID, which was not good for large numbers of backends: not only is the runtime O(N^2) but most of it is spent holding ProcArrayLock. Instead, take the lock just once and copy the active PIDs into an array, then use qsort and bsearch so that the lookup time is more like O(N log N).
Showing
Please register or sign in to comment