question

SHABOUMalek-9351 avatar image
0 Votes"
SHABOUMalek-9351 asked LakshminarayananAravind-0006 answered

<insufficient privilege> when query pg_stat_statements

Hello,

i have " <insufficient privilege>" in the query column of pg_stat_statements.


 SELECT substring(query, 1, 50) AS short_query,
               round(total_time::numeric, 2) AS total_time,
               calls,
               round(mean_time::numeric, 2) AS mean,
               round((100 * total_time /
               sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu
 FROM    pg_stat_statements
 ORDER BY total_time DESC
 LIMIT 20;
        short_query        | total_time | calls  |  mean  | percentage_cpu
 --------------------------+------------+--------+--------+----------------
  <insufficient privilege> |  271357.92 |  21922 |  12.38 |          30.75
  <insufficient privilege> |  261464.89 |  10961 |  23.85 |          29.63
  <insufficient privilege> |  249198.72 |   7307 |  34.10 |          28.24
  <insufficient privilege> |   40971.65 |  21922 |   1.87 |           4.64
  <insufficient privilege> |   17908.37 |  21922 |   0.82 |           2.03
 ...


i'm using a user how is membre of azure_pg_admin group.


azure-database-postgresql
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SHABOUMalek-9351, welcome to Microsoft Q&A forum.

Can you please tell me if you are seeing the 'insufficient privilege' for every record in the table? Or you are able to see the queries run by this specific user.

0 Votes 0 ·

Hi @SHABOUMalek-9351, could you please look into the previous comment and reply back in case you are still facing the issue.

0 Votes 0 ·

1 Answer

LakshminarayananAravind-0006 avatar image
0 Votes"
LakshminarayananAravind-0006 answered

Please grant 'pg_read_all_stats' role to the user using the command and check.

GRANT pg_read_all_stats TO <username>

Regards
Aravind

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.