2

In SQL Server when we have applications for which we do not have source code we could use the SQL Server profiler to analyze which queries or procedures are called when we do something in the application. Now I have similar situation with a .NET third party library and a Postgres database when it would be very useful to track queries called by that library. I found something similar in pgAdmin, but so far it appears to be useful to track only SQL queries that are executed in pgAdmin, not queries from external applications.

So to sum up: Is there a tool that allows me to track queries executed on a Postgres database from external applications?

EDIT: I tried to select from pg_stat_activity, but when I expect to see which stored procedures or statement is executed it prints only "COMMIT" string in the "query" column.

1
  • pg_stat_activity only shows the most recent statement that was executed, it does not show the history of all statements
    – user1822
    Commented Apr 23, 2020 at 13:45

1 Answer 1

2

Set log_statement = 'all' in postgresql.conf and reload PostgreSQL. Then all SQL statements will be written to the log.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.