Currently, I'm checking long running query in PostgreSQL.
To check this, I queried the command below:
SELECT pid, waiting, query_start, substr(query, 0, 50)
FROM pg_stat_activity
ORDER BY query_start
LIMIT 30;
And I get:
pid | waiting | query_start | substr
-------+---------+-------------------------------+------------------------------------------------------------------
26797 | f | 2015-07-06 12:44:04.418403+00 | SELECT * FROM "projects" WHERE "projects"."id" = $1 LIMIT 1
...
To analyse this long running query, I want to check the content of $1
of this prepared statement.
Are there any way to get this?
pg_stat_activity is a system view that allows you to identify active SQL queries in AnalyticDB for PostgreSQL instances. The pg_stat_activity view shows a server process and its related session and query in each row.
It is the backend's xmin horizon. That means that it is the oldest transaction ID whose effects may not be. visible to the transaction running in the backend. Since transaction IDs are stored in each row to determine its visibility, the minimum of the "backend_xmin" of all backends determines the cut-off.
PostgreSQL Usage. Use the ANALYZE command to collect statistics about a database, a table or a specific table column. The PostgreSQL ANALYZE command collects table statistics which support generation of efficient query execution plans by the query planner.
You will not get this info from pg_stat_activity, but you may get the full query from slow query log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With