top
If you want a snapshot of what your server is actually doing right now, from the operating system's perspective, top
is the easy tool to run. By default, it will sort the active processes by their CPU usage, and it's easy to sort other ways as well.
When looking at top
's memory accounting (which is similar to what ps
uses as well), you'll find three memory totals given. Both the VIRT
and SHR
figures include shared memory, and accordingly the total memory percentage shown for a PostgreSQL processes is probably inflated by some amount. Basically, any memory touched by the client backend from shared memory will get added to its total. The RES
figure is the more useful one to monitor for regular client processes.
The most useful top
trick to know is the fact that PostgreSQL processes update their process information based on what they're doing, essentially modifying what command line they appear to have been started with. Whether this happens or not depends...