OSDN Git Service

Rethink prior patch to filter out dead backend entries from the pgstats
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 16 Dec 2005 04:03:40 +0000 (04:03 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 16 Dec 2005 04:03:40 +0000 (04:03 +0000)
commitfb3dbdf986f0ab56e0a5177966bb0dec1f93444c
treee2d938afc400167c0b62d49bf37ed825ae0cbd70
parent4ce6be4f5e1e4b0c89c5c8de179e3fa8216a7b54
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).
src/backend/postmaster/pgstat.c
src/backend/storage/ipc/procarray.c
src/include/storage/procarray.h