We know that backend startup time is something we'd like to cut down as
much as possible, but has anyone ever looked at backend *shutdown* time?

I'm sitting here watching Michael Devogelaere's benchmark with "top",
and despite the fact that there's only one client process at a time,
there's frequently two or three backends running.  Sometimes four.
The only way I can see to explain this is that it takes a fair amount
of time for the backend to exit after the client disconnects.

Sample "ps -ef" run showing four active backends and one client:

tgl      17647     1  1 21:18 ?        00:02:31 postmaster -i -F
tgl      24844 17647  0 23:29 ?        00:00:00 postgres: userconsult_test userd
tgl      24852 17647  0 23:29 ?        00:00:00 postgres: userconsult_test userd
tgl      24856 17647  0 23:29 ?        00:00:00 postgres: userconsult_test userd
tgl      24859 17113  0 23:29 pts/1    00:00:00 /home/tgl/qmail/qmail-getpw alia
tgl      24860 17647  0 23:29 ?        00:00:00 postgres: userconsult_test userd

While it clearly takes some amount of time to clean out our entries in
the PROC array, etc, this trace suggests that the cost is a lot higher
than one would've expected.  Anyone have an idea what's going on here?

(BTW, the above processes are 7.1.3, but I doubt 7.2 is better.)

			regards, tom lane

Thu, 24 Jan 2002 23:38:22 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Backend shutdown time?
I said:
> While it clearly takes some amount of time to clean out our entries in
> the PROC array, etc, this trace suggests that the cost is a lot higher
> than one would've expected.  Anyone have an idea what's going on here?

Oh, never mind, I figured it out: the backends are all nice'd because
they're background processes.  As long as the client side wants cycles
(which it will, until it issues a query to the next backend) it's
hard for the exiting backend(s) to get any cycles at all.

			regards, tom lane

Thu, 24 Jan 2002 23:42:56 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Backend shutdown time? 