Rethink prior patch to filter out dead backend entries from the pgstats

Tom Lane <tgl@sss.pgh.pa.us>

Commit: fb3dbdf986f0ab56e0a5177966bb0dec1f93444c
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2005-12-16T04:03:40Z
Releases: 8.2.0
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).

Files