确定 PostgreSQL 中有问题的查询
有时我支持的 PostgreSQ 数据库会过载。我需要查明导致数据库过载的确切查询。我在相关时间范围内创建了 pgFounie 输出: http://bit.ly/f2aikx
在该报告中有一行
查询峰值:2011-03-15 10:41:06、2011-03-15 10:44:18、2011-03-15 10:48:25 4 个查询/秒
目前尚不清楚所提到的时间戳是否为峰值的开始或结束。
Sometimes a PostgreSQ database I support is overloaded. I need to pinpoint the exact queries that cause the database to be overloaded. I have created a pgFounie output on the relevant time frame:
http://bit.ly/f2aikx
In that report there is a row
Query peak: 4 queries/s at 2011-03-15 10:41:06, 2011-03-15 10:44:18, 2011-03-15 10:48:25
It is not clear whether the mentioned timestamps are for the start or end of the peak.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定问题是什么,但我会尝试一些事情:
“查询峰值”指标是指在三个单独的秒内,您看到每秒 4 个查询的峰值吞吐量。
以下是我如何精确定位有问题的查询:
EXPLAIN ANALYZE
以获取实际的执行计划。从长远来看,我会更改 pgFouine 中的设置,只记录执行时间超过 100 毫秒的查询。您可以使用 postgresql.conf 文件中的
log_min_duration_statement
设置来执行此操作。I'm not sure what the question is, but I'll take a stab at a few things:
The "Query peak" metric is referring to three separate seconds where you saw a peak throughput of 4 queries per second.
Here's how I would approach pinpointing your problematic queries:
EXPLAIN ANALYZE
on them to get actual execution plans.In the long run, I would change settings in pgFouine to only log queries that execute for over 100ms. You can do that using the
log_min_duration_statement
setting in the postgresql.conf file.