Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Transaction terminal-event time. |
| service | Utf8 | Owning application service. |
| transaction_name | Utf8 | Stable logical transaction class. |
| release | Utf8 | Application release. |
| duration_ms | Float64 | Begin-to-terminal transaction duration. |
| outcome | Utf8 | committed, rolled_back, or timed_out. |
Copy the query
SELECT
service,
transaction_name,
release,
COUNT(*) AS transactions,
approx_percentile_cont(duration_ms, 0.95) AS p95_duration_ms,
MAX(duration_ms) AS max_duration_ms,
SUM(CASE WHEN outcome <> 'committed' THEN 1 ELSE 0 END) AS unsuccessful
FROM database_transaction_events
WHERE timestamp_utc >= now() - INTERVAL '7 days'
GROUP BY service, transaction_name, release
ORDER BY p95_duration_ms DESC, unsuccessful DESC;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
p95 transaction duration
Invoice finalization has the longest tail and the most unsuccessful outcomes.
| service | transaction_name | release | transactions | p95_duration_ms | max_duration_ms | unsuccessful |
|---|---|---|---|---|---|---|
| billing | invoice-finalize | api-88 | 820 | 6,800 | 24,100 | 28 |
| projects | member-import | api-88 | 240 | 4,210 | 18,200 | 9 |
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, illustrative input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.
How the SQL works
- 1Transaction class connects duration to an application owner.
- 2The maximum exposes extreme resource holds beside a stable percentile.
- 3Non-commit outcomes include rollback and timeout for a full terminal view.
Edge cases to decide
- Missing terminal events need a separate start-to-terminal join.
- Server wait events and lock graphs require database-native diagnostics.
- Do not log statements with bound values.
Recommended dashboard
- Bars: p95_duration_ms by transaction
- Trend: unsuccessful by release
- Table: longest safe transaction events
Alert guidance
Alert when a critical transaction times out or its p95 exceeds an owner-approved bound.
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.