Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Query completion time in UTC. |
| request_id | Utf8 | Bounded request correlation identifier. |
| route_template | Utf8 | Stable application route. |
| query_fingerprint | Utf8 | Normalized query shape without parameters. |
| sequence_in_request | Int64 | Query order inside the request. |
| duration_ms | Float64 | Database operation duration. |
| environment | Utf8 | Deployment environment. |
Copy the query
WITH queries_per_request AS (
SELECT
route_template,
query_fingerprint,
request_id,
COUNT(*) AS executions_in_request
FROM database_request_query_events
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
AND environment = 'production'
GROUP BY route_template, query_fingerprint, request_id
)
SELECT
route_template,
query_fingerprint,
COUNT(*) AS requests,
SUM(CASE WHEN executions_in_request >= 5 THEN 1 ELSE 0 END)
AS requests_with_repeats,
AVG(executions_in_request) AS average_executions_per_request,
MAX(executions_in_request) AS maximum_executions_in_request
FROM queries_per_request
GROUP BY route_template, query_fingerprint
ORDER BY requests_with_repeats DESC, route_template;This read-only query is planned and executed against an empty typed table with Apache DataFusion 45.2.0. The deterministic sample output is synthetic and reviewed separately; validate field types, thresholds, and business definitions against your own data. Read the testing methodology.
Query result
Repeated queries inside requests
The checkout route repeats its line-item fingerprint at least five times in two requests.
| route_template | query_fingerprint | requests | requests_with_repeats | average_executions_per_request | maximum_executions_in_request |
|---|---|---|---|---|---|
| /api/checkout | SELECT line_items BY order_id | 3 | 2 | 4 | 6 |
| /api/profile | SELECT user WITH preferences | 3 | 0 | 1 | 1 |
Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.
Reproduce the example
Download the public fixture
The JSON bundle includes the typed event contract, reproducible input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.
How the SQL works
- 1The inner query establishes request-level repetition before any route-level aggregation.
- 2A controlled fingerprint groups equivalent parameterized operations without retaining raw SQL values.
- 3Both prevalence and worst-case repetition are preserved so one extreme request does not look systemic.
Edge cases to decide
- Choose a threshold that fits intentional batching and pagination behavior.
- Async work needs a correlation identifier that survives the handoff from request to worker.
- Sampling query events can hide exact repetition counts; use trace-aware sampling or document the estimate.
Recommended dashboard
- Bars: requests_with_repeats by route and fingerprint
- Trend: average executions per request by release
- Trace link: query sequence for a selected request_id
Alert guidance
Prefer a release regression alert when repeated-query prevalence rises materially, rather than paging on one request.
Read alert setupPut the recipe to work
Related instrumentation and guides
Continue the analysis
Find Slow Database Queries by Fingerprint
Rank normalized database operations by slow-query rate, average duration, and worst observed duration without storing raw SQL or parameters.
Open recipeMeasure Database Connection-Pool Saturation
Measure average pool utilization, queued acquisition waits, timeouts, and idle capacity by application service.
Open recipeCalculate Database Transaction Rollback Rate
Compare committed and rolled-back transactions by service while preserving error categories, duration, and affected accounts.
Open recipeRun it on real events
Create a table, adapt the fields, and save the result
Start free, send structured events, and use the query result as a chart, shared dashboard widget, or alert input.