获取执行次数最多的语句

最近更新时间: 2024-10-17 17:10:00

postgres=# select 
    pg_authid.rolname as rolname,
    pg_database.datname as datname,
    pg_stat_statements.query,
    pg_stat_statements.calls,
    pg_stat_statements.total_time, 
    round((pg_stat_statements.total_time/pg_stat_statements.calls)::numeric,6) as runtime_of_once 
from 
    pg_stat_statements
    inner join pg_authid on pg_authid.oid=pg_stat_statements.userid 
    inner join pg_database on pg_database.oid= pg_stat_statements.dbid
order by 
    pg_stat_statements.calls desc 
limit 10;