I'm running the following query:
`SELECT query_start, query, pid, state FROM pg_stat_activity WHERE datname='${my_database}' AND usename='${my_user}' AND pid<>pg_backend_pid() ORDER BY query_start;`
Whilst there are many rows with meaningful info like:
there are also many rows with null info:
Is this normal? These null entries don't seem to persist, so maybe they just relate to queries that are in the process of being set up? Or something?
CodePudding user response:
The key is the state
column: those which have no query_start
are the ones with state = 'idle'
. Idle connections are not currently executing a query.
What is confusing you is that the query
column is not, as you assume, the currently running query, but the last query that was executed on that connection.