Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL - pg_monitor role

I have problem - probably with postgres permissions. I created a user and granted role to him:

CREATE USER test PASSWORD 'abc';
GRANT pg_monitor TO test;

Next I want to login as test user and run query:

select * from pg_stat_progress_vacuum;

But unfortunately user does not have sufficient permissions and i can't see some info from this select (for example i can't see relid info)

Sample output:

 pid  |   datid   |     datname      | relid | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
-------+-----------+------------------+-------+-------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
 1241 | 213123214 | database1 |       |       |                 |                   |                    |                    |                 |

PS. I have PostgreSQL 12.2

like image 888
Xavier123 Avatar asked Dec 02 '25 10:12

Xavier123


1 Answers

You say you can't see the pid, but the example you show is clearly showing the pid. I assume it the other 8 columns, starting with "relid", that you can't see.

This works for me. When pg_monitor is granted and a vacuum is running, I see data in all columns, and when it not granted I see the final 8 columns being NULL.

This looks like some kind of user error, like you are connecting as the wrong user, or to the wrong server, or the GRANT is not actually being executed.

like image 174
jjanes Avatar answered Dec 05 '25 00:12

jjanes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!