---
title: Attribute non-SQL time in data-view slow-query signals
type: task
status: planned
description: >-
  The ██████████ graded duration covers build, pool acquire, statement and post-processing, so an
  8.9s firing whose SQL ran 3.7s is unattributable. Split statement time and event-loop delay into
  the telemetry and payload, then attribute signature 090c5c6897c979b1's 4-5s stalls.
base_uri: user:task/league/data-views/attribute-non-sql-time-in-data-view-slow-query-signals.md
created_at: '2026-09-30T03:35:57.582Z'
entity_id: 5884d84c-083a-4162-876e-a217b707f99e
observations:
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
  - ████████████████████████████████████████████████
owner_identity_uri: █████████████████████████
priority: Low
public_read: true
relations:
  - relates [[█████████████████████-████████████-██-██████-████-████-█████-█████████]]
  - relates [[█████████████████████-██████████-███-███████-██████████-███-████-████-███████]]
tags:
  - user:tag/league-xo-football.md
  - user:tag/software-task.md
updated_at: '2026-11-06T00:03:47.780Z'
visibility_analyzed_at: '2026-11-06T00:17:44.326Z'
---

## Overview

The `██████████` detector grades `query_execution_duration_ms`, which is measured around the whole `resolved_run_query` call in `libs-server/data-views/execute-data-view-request.mjs`. That covers the query build, the knex pool acquire, the statement, `resolve_pg_field_types` and anything else that holds the Node event loop. So a firing cannot separate a slow statement from a stalled API process.

Signature `090c5c6897c979b1` (user 130, view `9b7c2fc6`, 25 per-game from-plays columns over 2025-2026) shows the gap. It fired twice, and both times its SQL was under the 5s objective:

| Signal | Graded | Statement (postgres log) | Unattributed | Where the gap sits |
| --- | --- | --- | --- | --- |
| 131654 (2026-09-22 20:57) | 8,405ms | 3,977ms | ~4.4s | after the statement returned |
| 133037 (2026-09-29 20:56) | 8,869ms | 3,735ms | ~5.1s | before the statement began |

What was ruled out, all measured on host `league`:

- The build takes 20-55ms and the SQL 3.45-3.58s, driving the deployed builder with the saved table state 3x on a quiet host.
- 44 other runs of the same signature ran 3.2-4.8s.
- Admission wait was 1ms.
- The CTE budget arm did not fire; the statement ran under `statement_timeout = 8000` and finished.
- No slow statement from another backend was logged in the window.
- The Redis slowlog maxes at ~15ms, with zero evictions.
- There was no pm2 restart near either window.
- No `KnexTimeoutError` was logged.

For 133037 the client reported 16,721ms against the server's 8,869ms. Other signals show a 40-185ms client gap. A stall of the whole process, the event loop or the pool, fits both sides. It is unproven.

## Plan

- [ ] Split the graded figure in the execution telemetry line and the `██████████` payload into `statement_ms`, timed around the pg round trip only, and the remainder. Also record the max event-loop delay over the request window (`perf_hooks.monitorEventLoopDelay`) and the pool's pending-acquire count at dispatch.
- [ ] Decide what the detector grades. Recommendation: keep grading the user-facing total, and name `statement_ms` and the event-loop delay in the payload so triage can route a process stall away from the query-shape owners.
- [ ] Deploy (operator-gated). On the next firing where `statement_ms` is under the threshold, identify the stall source from the recorded split.
- [ ] Close 133037 with the attribution.

## Not this task

- The query-shape cost of the wide from-plays family belongs to [[█████████████████████-████████████-██-██████-████-████-█████-█████████]]. Signature `090c5c6897c979b1` is NOT in that family's slow class; its statement is ~4s.
