1

I have multi-tenant postgres DB. I can see details from pg_stat_statements table in the public schema with no issues, but as soon as I switch to a different schema - I get no visibility.

What could be done?

prod=> SET search_path=schema_name;
SET
prod=> SELECT substring(query, 1, 130) AS query,
      calls,
      round(total_exec_time::numeric, 2) AS total_time,
      round(mean_exec_time::numeric, 2) AS mean_time,
      round((100 * total_exec_time / sum(total_exec_time) OVER ())::numeric, 2) AS percentage
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;
ERROR:  relation "pg_stat_statements" does not exist
LINE 6: FROM pg_stat_statements
             ^
prod=> create extension pg_stat_statements;
ERROR:  extension "pg_stat_statements" already exists

prod=> 
DmitrySemenov
  • 9,204
  • 15
  • 76
  • 121

0 Answers0