gprof

The standard GNU profiler, gprof, is available for most Unix-like systems. If you compile the PostgreSQL server using the --enable-profiling option, it will produce a gmon.out file that can be given to gprof for verbose profiling of the server internals.

The main issue with gprof profiling and PostgreSQL is that it's known to have problems when tracing into functions in loadable libraries. Also, it's hard to combine the profiling information with a look at what the underlying operating systems is doing. These two limitations combine to make gprof only suitable for profiling fairly simple and pure database operations.

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.