Fix/slow queries threshold filter - #3
Merged
Merged
Conversation
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.
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
force-pushed
the
fix/slow-queries-threshold-filter
branch
from
May 15, 2026 10:38
7d305ae to
ca51f09
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
slow_queriesendpoint now filters queries to only include those with a 95th percentile latency (p95_us) above a configurable threshold, derived from theslow_query_mssetting in the proxy configuration. This ensures that only genuinely slow queries are reported.Anomaly detection robustness:
HeatmapStorenow 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 featurefix— bug fixperf— performance improvementrefactor— code change without feat/fixdocs— documentation onlytest— adding or updating testsci— CI/CD changeschore— maintenanceRelated Issue
Closes #
Checklist
cargo fmt --allpassescargo clippy --all-targets -- -D warningspassescargo test --libpasses locally