How do you enable pg_stat_statements?

The official list of supported extensions in Render’s docs includes pg_stat_statements as an option. However, connecting to my database indicates that pg_stat_statements is already enabled:

database_txxx=> create extension pg_stat_statements;
ERROR:  extension "pg_stat_statements" already exists

But the views that you’d expect to exist if it was enabled don’t exist:

database_txxx=> select * from pg_stat_statements limit 10;
ERROR:  relation "pg_stat_statements" does not exist

And the docs for pg_stat_statements suggests that you need to enable it in preload libraries because it requires additional space:

The module must be loaded by adding pg_stat_statements to shared_preload_libraries in postgresql.conf , because it requires additional shared memory.

So: is pg_stat_statements something that Render databases can support? Is it enabled, but I can’t access its view and methods? Do I need to restart my database to get it working?

Hi Tom,

This should work. I just set this up from scratch and got it working with out any trouble.

You may need to add permissions for your user

GRANT pg_read_all_stats TO <user>;

But if that were the problem, I’d expect to see a different error. If you can afford a bit of downtime for a database restart you could certainly try that just to see if it helps.

Otherwise, could you send me your database id? Feel free to open a support ticket if you don’t want to share this in a public forum.



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.