在PostgreSQL上分析/分析查询 [英] Analysing/Profiling queries on PostgreSQL

查看:101
本文介绍了在PostgreSQL上分析/分析查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚继承了旧的PostgreSQL安装,需要进行一些诊断以找出为什么该数据库运行缓慢.在MS SQL上,您将使用Profiler之类的工具查看正在运行的查询,然后查看其执行计划.

I've just inherited an old PostgreSQL installation and need to do some diagnostics to find out why this database is running slow. On MS SQL you would use a tool such as Profiler to see what queries are running and then see how their execution plan looks like.

我可以使用哪些工具(如果有的话)为PostgreSQL?我将不胜感激,因为我对Postgres很陌生.

What tools, if any, exist for PostgreSQL that I can do this with? I would appreciate any help since I´m quite new with Postgres.

推荐答案

使用 pg_stat_statements 扩展名以获取长期运行的查询.然后使用pg_stat_statements顺序中的select *,按total_time/calls dec限制10来获得十个最长的时间.然后使用解释来查看计划...

Use pg_stat_statements extension to get long running queries. then use select* from pg_stat_statements order by total_time/calls desc limit 10 to get ten longest. then use explain to see the plan...

这篇关于在PostgreSQL上分析/分析查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆