8000 feature: aligned the calculation of pg_wait_sampling and pgpro_stats … · postgrespro/mamonsu@8e4cd38 · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit 8e4cd38

Browse files
committed
feature: aligned the calculation of pg_wait_sampling and pgpro_stats metrics
1 parent ec2c153 commit 8e4cd38

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mamonsu/plugins/pgsql/wait_sampling.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ class WaitSampling(Plugin):
2727
WHEN event_type = 'Lock' THEN 'hwlock'
2828
ELSE 'buffer'
2929
END,
30-
sum(count) AS count
30+
sum(count * current_setting('pg_wait_sampling.profile_period')::bigint) AS count
3131
FROM {extension_schema}.pg_wait_sampling_profile
3232
WHERE event_type is not null
33+
AND queryid IS NOT NULL AND queryid != 0
3334
GROUP BY 1
3435
ORDER BY count DESC;
3536
""",
@@ -93,9 +94,10 @@ class WaitSampling(Plugin):
9394
"""
9495
SELECT
9596
event,
96-
sum(count) AS count
97+
sum(count * current_setting('pg_wait_sampling.profile_period')::bigint) AS count
9798
FROM {extension_schema}.pg_wait_sampling_profile
9899
WHERE event_type = 'Lock'
100+
AND queryid IS NOT NULL AND queryid != 0
99101
GROUP BY 1
100102
ORDER BY count DESC;
101103
""",
@@ -157,9 +159,10 @@ class WaitSampling(Plugin):
157159
WHEN event = 'buffer_mapping' THEN 'buffer'
158160
ELSE 'other'
159161
END,
160-
sum(count) AS count
162+
sum(count * current_setting('pg_wait_sampling.profile_period')::bigint) AS count
161163
FROM {extension_schema}.pg_wait_sampling_profile
162164
WHERE event_type = 'LWLockTranche' OR event_type = 'LWLockNamed'
165+
AND queryid IS NOT NULL AND queryid != 0
163166
GROUP BY 1
164167
ORDER BY count DESC;
165168
""",

0 commit comments

Comments
 (0)
0