Skip to content

Commit e325dc2

Browse files
committed
fix: apply WHERE filter to postgres sink, remove LIMIT from both sinks
The 100K queryids came from the postgres sink path having no filter at all — not from the WHERE filter being too weak. LIMIT 100 was the wrong fix; the filter itself is sufficient when applied everywhere. - postgres sink (pgss_queryid_queries): add the same WHERE filter (calls >= 5 or total_exec_time >= 1000) instead of LIMIT 100 - prometheus sink (pg_stat_statements): remove LIMIT 100, keep the WHERE filter only https://claude.ai/code/session_01SzJxzZNQjDQphaHyaX3RU7
1 parent b858689 commit e325dc2

2 files changed

Lines changed: 1 addition & 3 deletions

File tree

config/pgwatch-postgres/metrics.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ metrics:
1111
where
1212
queryid is not null
1313
and dbid = (select oid from pg_database where datname = current_database())
14+
and (calls >= 5 or total_exec_time >= 1000)
1415
order by total_exec_time desc
15-
limit 100
1616
gauges:
1717
- '*'
1818

config/pgwatch-prometheus/metrics.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,6 @@ metrics:
10371037
from aggregated_statements
10381038
where calls >= 5 or exec_time_total >= 1000
10391039
order by exec_time_total desc
1040-
limit 100
10411040
17: |
10421041
with aggregated_statements as ( /* pgwatch_generated */
10431042
select
@@ -1086,7 +1085,6 @@ metrics:
10861085
from aggregated_statements
10871086
where calls >= 5 or exec_time_total >= 1000
10881087
order by exec_time_total desc
1089-
limit 100
10901088
gauges:
10911089
- calls
10921090
- plans_total

0 commit comments

Comments
 (0)