Skip to content

Commit 0cdacb8

Browse files
committed
fix: use WHERE filter instead of LIMIT for pgss queryid cardinality control
Replace ORDER BY calls DESC LIMIT 100 with: WHERE calls >= 5 OR exec_time_total >= 1000 This keeps all meaningful queries (both frequent AND rare-but-slow) while filtering PostgREST noise (one-off queries with <5 calls and <1s total time). The sample_limit: 5000 in prometheus.yml acts as a safety net if cardinality is still too high. https://claude.ai/code/session_01SzJxzZNQjDQphaHyaX3RU7
1 parent 7d69338 commit 0cdacb8

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

config/pgwatch-prometheus/metrics.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,7 @@ metrics:
10351035
temp_bytes_read::int8 as temp_bytes_read,
10361036
temp_bytes_written::int8 as temp_bytes_written
10371037
from aggregated_statements
1038-
order by calls desc
1039-
limit 100
1038+
where calls >= 5 or exec_time_total >= 1000
10401039
17: |
10411040
with aggregated_statements as ( /* pgwatch_generated */
10421041
select
@@ -1083,8 +1082,7 @@ metrics:
10831082
temp_bytes_read::int8 as temp_bytes_read,
10841083
temp_bytes_written::int8 as temp_bytes_written
10851084
from aggregated_statements
1086-
order by calls desc
1087-
limit 100
1085+
where calls >= 5 or exec_time_total >= 1000
10881086
gauges:
10891087
- calls
10901088
- plans_total

0 commit comments

Comments
 (0)