Follow these steps to examine the PostgreSQL processes in various ways:
- In our PostgreSQL connection, execute the following query to find the PID of the server backend assigned to us:
SELECT pg_backend_pid() AS pid;
- As our root-capable user, attach strace to the preceding PID (4200, for example) with this command:
sudo strace -p 4200
- In our PostgreSQL connection, execute the following query to generate some activity:
SELECT 1;
- In the Terminal where strace is running, press Ctrl + C to disconnect.
- Attach strace again, but collect the statistics with the following command:
sudo strace -c -S calls -p 4200
- Now, execute the following query to generate some complex activity:
SELECT * FROM information_schema.columns;