I use a database tool (Elixir Ecto) that uses prepared statements for most PostgreSQL queries. I want to see how and when he does it.
I found the correct Postgres configuration file, postgresql.conf , by executing the SHOW config_file; in psql . I edited it to enable
log_statement = 'all'
as suggested by Dogbert here .
According to PostgreSQL 9.6 docs, this parameter should call PREPARE statements.
After rebooting PostgreSQL, I can tail -f its log file (the one specified with the value -r when executing the postgres executable), and I see entries like this:
LOG: execute ecto_728: SELECT i0."id", i0."store_id", i0."title", i0."description" FROM "items" AS i0 WHERE (i0."description" LIKE $1) DETAIL: parameters: $1 = '%foo%'
This matches the request (although it is executed using the binary protocol, I think), for example
EXECUTE ecto_728('%foo%');
However, I do not see the original PREPARE that ecto_728 created .
I tried to reset and recreate the database. Subsequently, the same query is executed as ecto_578 , so it seems that the original prepared statement was deleted from the database and a new one was created.
But when I look at the PostgreSQL log for ecto_578 , I see that it is running, not being created.
How can I see PREPARE statements in a PostgreSQL log?