Skip to content

Fix/slow queries threshold filter - #3

Merged
denerFernandes merged 2 commits into
masterfrom
fix/slow-queries-threshold-filter
May 15, 2026
Merged

denerFernandes merged 2 commits into
masterfrom
fix/slow-queries-threshold-filter

Conversation

@denerFernandes

@denerFernandes denerFernandes commented May 15, 2026

Copy link
Copy Markdown
Member

Summary

This pull request improves the accuracy and reliability of slow query detection and anomaly flagging in the dashboard. The main changes include filtering slow queries based on a configurable threshold and making anomaly detection less sensitive to low-traffic periods.

Slow query filtering improvements:

  • The slow_queries endpoint now filters queries to only include those with a 95th percentile latency (p95_us) above a configurable threshold, derived from the slow_query_ms setting in the proxy configuration. This ensures that only genuinely slow queries are reported.

Anomaly detection robustness:

  • The anomaly detection logic in HeatmapStore now requires at least 12 active cells (hours with traffic) before flagging spikes as anomalies. This change helps avoid false positives, especially right after the proxy starts or during low-traffic periods.

Type of Change

  • feat — new feature
  • fix — bug fix
  • perf — performance improvement
  • refactor — code change without feat/fix
  • docs — documentation only
  • test — adding or updating tests
  • ci — CI/CD changes
  • chore — maintenance

Related Issue

Closes #

Checklist

  • Commit messages follow Conventional Commits
  • cargo fmt --all passes
  • cargo clippy --all-targets -- -D warnings passes
  • Tests added or updated for logic changes
  • cargo test --lib passes locally
  • Documentation updated (if applicable)

The /api/slow-queries endpoint was returning top queries by p95
regardless of actual latency. Now it only shows queries whose p95
exceeds the configured slow_query_ms threshold, preventing fast
queries like PING from appearing in the slow queries panel.
@denerFernandes denerFernandes self-assigned this May 15, 2026
When a PostgreSQL connection with prepared statements is returned to
the pool, server-side statements persist on the backend. If another
client reuses that connection and issues a Parse with the same name,
PostgreSQL returns 'prepared statement already exists'. This fix sends
DEALLOCATE ALL before returning stmt_conn, ensuring a clean slate.
@denerFernandes
denerFernandes force-pushed the fix/slow-queries-threshold-filter branch from 7d305ae to ca51f09 Compare May 15, 2026 10:38
@denerFernandes
denerFernandes merged commit 80a2578 into master May 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant