Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg_stat_statement extension only gives you access to your own queries #102

Open
tlwr opened this issue May 1, 2019 · 2 comments
Open

pg_stat_statement extension only gives you access to your own queries #102

tlwr opened this issue May 1, 2019 · 2 comments

Comments

@tlwr
Copy link

tlwr commented May 1, 2019

When using pg_stat_statement you can only look at your own queries, which is expected behaviour, but suboptimal for users who want to inspect queries from multiple bindings.

> SELECT (total_time / 1000 / 60) as total_minutes,
         (total_time/calls) as average_time,
         query
  FROM pg_stat_statements p 

total_minutes |   average_time   |          query           
---------+---------------+------------------+--------------------------
199.0077556 | 333.073461212308 | <insufficient privilege>
@richardTowers
Copy link
Contributor

🤔 interesting. Any thoughts on how we could fix this?

@tlwr
Copy link
Author

tlwr commented May 1, 2019

We could do something like this filthy pseudo-sql when we create the binding

BEGIN
  SELECT true FROM pg_extension WHERE extname = 'pg_stat_statement';

  IF FOUND THEN
    GRANT SELECT ON pg_stat_statements TO $1;
  END IF;
END; $$ LANGUAGE plpgsql;

Where $1 is the user for a binding, or do the above based on the binding args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants