0

"select * from pg_stat_activity"为了列出现有的连接,有 100 多个打开的连接,状态为“idle in transaction”,查询如下:

SELECT c.oid, a.attnum, a.attname, c.relname, n.nspname, 
       a.attnotnull OR (t.typtype = 'd' AND t.typnotnull),
       a.attidentity != '' OR pg_catalog.pg_get_expr(d.adbin, d.adrelid) LIKE '%nextval(%' 
FROM pg_catalog.pg_class c 
  JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid) 
  JOIN pg_catalog.pg_attribute a ON (c.oid = a.attrelid) 
  JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) 
  LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = a.attrelid AND d.adnum = a.attnum) 
  JOIN (SELECT 21826 AS oid , 9 AS attnum UNION ALL SELECT 21826, 3) vals ON (c.oid = vals.oid AND a.attnum = vals.attnum)

谷歌表示,它是获取元数据的查询及其由框架生成的。我检查了我的代码库,没有地方可以调用这个查询。我想知道,为什么这些连接仍然处于*“idle in transaction”状态并且仍然处于打开状态;这导致繁忙的连接。

4

0 回答 0