-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
環境
・OS : Red Hat Enterprise Linux 9.2
・PostgreSQL : 15.4
・pg-statsinfo : 15.3
pg_statsinfoリポジトリに複数インスタンスの情報を格納している場合、"/** Database Resource Usage(rusage) **/"レポートを出力する statsrepo.get_db_rusage_report 関数が正しい情報を出力できていなように思えます。
https://github.com/ossc-db/pg_statsinfo/blob/15/agent/bin/pg_statsrepo.sql#L1330
statsrepo.get_dbsize_tendency_report 関数などのように、instidによる絞込みがないため、別インスタンスの情報も計算結果に含まれる動作になっています。
下記のような修正が必要になると思います。ご確認の上、修正のご検討をお願いいたします。
変更前:(pg_statsrepo.sql)1359行目~1369行目
SELECT snapid, dbid, userid, queryid,
statsrepo.np_sub(plan_reads, lag(plan_reads, 1) OVER w) AS plan_reads,
statsrepo.np_sub(plan_writes, lag(plan_writes, 1) OVER w) AS plan_writes,
statsrepo.np_sub(plan_user_time, lag(plan_user_time, 1) OVER w) AS plan_user_time ,
statsrepo.np_sub(plan_system_time, lag(plan_system_time, 1) OVER w) AS plan_system_time,
statsrepo.np_sub(exec_reads, lag(exec_reads, 1) OVER w) AS exec_reads,
statsrepo.np_sub(exec_writes, lag(exec_writes, 1) OVER w) AS exec_writes,
statsrepo.np_sub(exec_user_time, lag(exec_user_time, 1) OVER w) AS exec_user_time,
statsrepo.np_sub(exec_system_time, lag(exec_system_time, 1) OVER w) AS exec_system_time
FROM
statsrepo.rusage WHERE snapid BETWEEN $1 AND $2 WINDOW w AS (PARTITION BY dbid, userid, queryid ORDER BY snapid)
修正案
SELECT ru.snapid, dbid, userid, queryid,
statsrepo.np_sub(plan_reads, lag(plan_reads, 1) OVER w) AS plan_reads,
statsrepo.np_sub(plan_writes, lag(plan_writes, 1) OVER w) AS plan_writes,
statsrepo.np_sub(plan_user_time, lag(plan_user_time, 1) OVER w) AS plan_user_time ,
statsrepo.np_sub(plan_system_time, lag(plan_system_time, 1) OVER w) AS plan_system_time,
statsrepo.np_sub(exec_reads, lag(exec_reads, 1) OVER w) AS exec_reads,
statsrepo.np_sub(exec_writes, lag(exec_writes, 1) OVER w) AS exec_writes,
statsrepo.np_sub(exec_user_time, lag(exec_user_time, 1) OVER w) AS exec_user_time,
statsrepo.np_sub(exec_system_time, lag(exec_system_time, 1) OVER w) AS exec_system_time
FROM
statsrepo.rusage ru INNER JOIN statsrepo.snapshot s ON ru.snapid = s.snapid AND s.instid = (SELECT instid FROM statsrepo.snapshot where snapid = $2)
WHERE ru.snapid BETWEEN $1 AND $2 WINDOW w AS (PARTITION BY dbid, userid, queryid ORDER BY ru.snapid)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels