Thread: pgsql: Rethink prior patch to filter out dead backend entries from the

pgsql: Rethink prior patch to filter out dead backend entries from the

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
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).

Modified Files:
--------------
    pgsql/src/backend/postmaster:
        pgstat.c (r1.112 -> r1.113)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/postmaster/pgstat.c.diff?r1=1.112&r2=1.113)
    pgsql/src/backend/storage/ipc:
        procarray.c (r1.9 -> r1.10)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/ipc/procarray.c.diff?r1=1.9&r2=1.10)
    pgsql/src/include/storage:
        procarray.h (r1.6 -> r1.7)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/procarray.h.diff?r1=1.6&r2=1.7)