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 the memory accounting of top (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 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 ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.