What does it mean when Postgres query state is null
-
23-02-2021 - |
Question
What does it mean when a query state is null
?
my_database_name> SELECT pid, datname, usename, application_name, query_start, state, state_change FROM pg_stat_activity;
+-------+------------------+------------------+--------------------------+-------------------------------+---------+-------------------------------+
| pid | datname | usename | application_name | query_start | state | state_change |
|-------+------------------+------------------+--------------------------+-------------------------------+---------+-------------------------------|
| 19093 | my_database_name | my_user_nam | pgcli | 2020-02-07 12:58:54.665447+00 | active | 2020-02-07 12:58:54.665449+00 |
| 13777 | my_database_name | some_other_user | DBeaver 6.3.2 - Main | <null> | <null> | <null> |
| 13776 | my_database_name | some_other_user | DBeaver 6.3.2 - Metadata | <null> | <null> | <null> |
| 2036 | <null> | <null> | | <null> | <null> | <null> |
+-------+------------------+------------------+--------------------------+-------------------------------+---------+-------------------------------+
Solution
It means that the session with pid
2036 belongs to a different user, and you don't have the privileges to see that data.
Consider that the queries run in that session might contain data that you have no right to see.
You must either be a superuser or (in recent versions) be a member of the pg_read_all_stats
role to see these data.
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange