磐维数据库查询历史SQL执行时长

查询SQL执行时间超过2秒的语句为:

select * from dbe_perf.statement_history where timestampdiff(second,start_time::timestamp(0) without time zone,finish_time::timestamp(0) without time zone)>2;

其中timestampdiff在B模式可用(兼容MySQL模式),timestampdiff的具体用法可以参考:https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/BriefTutorial/时间-日期函数和操作符.html

dbe_perf.statement_history 各字段的含义可以参考:https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/DatabaseReference/STATEMENT_HISTORY.html

或者使用如下SQL查询:

select * from dbe_perf.statement_history where extract(epoch from finish_time-start_time)>1;

extract用法、含义参考:https://docs-opengauss.osinfra.cn/zh/docs/5.0.0/docs/BriefTutorial/时间-日期函数和操作符.html

posted @ 2024-11-12 22:07  PanWei_DBA  阅读(65)  评论(0)    收藏  举报