本文介绍了有没有一种方法可以在不使用SQL连接的情况下获取pg_stat_activity信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pg_stat_activity 拥有非常有用的信息,可以对各种问题进行事后分析,尤其是与并发相关的信息,因此可以使用此数据来扩大错误或记录日志(正确过滤和关联)是无价的但是,查询它需要获得一个数据库连接,而该数据库连接在最需要的那一刻可能会短缺。

pg_stat_activity holds extremely useful information for post-mortem analysis of various issues, especially concurrency-related, and so augmenting errors or logging with this data (properly filtered and correlated) is invaluable. However querying it requires getting a database connection which might be in short supply at the very moment it's most needed.

是否存在某种旁通道,该通道可以使

Is there a side-channel of some sort which would allow getting that information without the additional database connection?

推荐答案

不是真的,但是参数 superuser_reserved_connections 会帮助您。它精确地定义了为超级用户保留的连接数,以便即使连接限制已用尽,超级用户仍然可以连接。

Not really, but the parameter superuser_reserved_connections will help you. It defines the number of connections that are reserved for superusers precisely so that they can still connect, even if the connection limit is exhausted.

将值设置得足够高并使您的监视进程以超级用户身份连接。

Set the value high enough and have your monitoring process connect as superuser.

这篇关于有没有一种方法可以在不使用SQL连接的情况下获取pg_stat_activity信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 15:07