数据库
首页 > 数据库> > postgresql 监控 - 洞察力

postgresql 监控 - 洞察力

作者:互联网

1. 监控请求数据  The total number of connected clients and their states (active, idle in transaction, waiting)

SELECT COUNT
    ( * ) FILTER ( WHERE STATE IS NOT NULL ) AS total,
    COUNT ( * ) FILTER ( WHERE STATE = 'idle' ) AS idle,
    COUNT ( * ) FILTER ( WHERE STATE IN ( 'idle in transaction', 'idle in transaction (aborted)' ) ) AS idle_in_xact,
    COUNT ( * ) FILTER ( WHERE STATE = 'active' ) AS active,
    COUNT ( * ) FILTER ( WHERE wait_event_type = 'Lock' ) AS waiting,
    COUNT ( * ) FILTER ( WHERE STATE IN ( 'fastpath function call', 'disabled' ) ) AS OTHERS 
FROM
    pg_stat_activity 
WHERE
    backend_type = 'client backend';

越 接近情报,越增加财富

听大佬的直播,第一手资料

标签:COUNT,postgresql,STATE,FILTER,idle,监控,洞察力,active,WHERE
来源: https://www.cnblogs.com/hixiaowei/p/16576153.html