When pages stall, APIs slow down and cloud bills keep growing, the cause is rarely one setting. We trace the complete journey—from the first interaction to the database, infrastructure and AI services behind it—then build and verify the changes that matter.
We used 50,000 real NYC 311 records to investigate the database work behind a service dashboard. Two targeted indexes cut query time in our local experiment; result checks and storage measurements show the tradeoff.
IndependentNot a client engagement. This study was not commissioned by, affiliated with or endorsed by SQLite or the other organisations discussed. Findings, local experiments and proposed work are identified separately.
Evidence at a glance
What we can substantiate.
Real records50,000
Unique request identifiers, with six selected fields and no customer names or addresses.[1][2]
Indexed query median0.52 ms
Baseline 14.55 ms; same 50 result rows for the timed Brooklyn / NYPD request.[1]
Result comparisons142
Two queries × 71 observed borough–agency combinations; every result matched.[1]
Storage tradeoff+5.44 MB
Both indexes plus planner statistics increased the database from 4,829,184 to 10,272,768 bytes.[1]
Measured local experiment · Studied 12 October 2026 · By SystemVale
The question
A slow report is often a question about work done for each answer—not simply a shortage of servers.
1Can the database jump to the requested records instead of inspecting the whole table?
2Can it produce the requested order without sorting an intermediate result?
3Does the extra index storage justify the reduction in repeated query work?
Scope & method
A bounded question. A repeatable method.
SQLite 3.42.0 through Python 3.11.5 on Windows 10. The dataset is the first 50,000 unique keys in ascending order among records created in January 2025; its actual timestamps cover 1–5 January. This is a reproducible workload sample, not a representative sample of the month. We did not test NYC’s production database, a hosted application or Datasette’s HTTP layer.
Step 01
Freeze the workload
Save the source response and its SHA-256 hash. Create two databases with identical rows and the same primary key. Fix the timed filter to Brooklyn / NYPD and keep query text, selected columns and result ordering identical.
Step 02
Explain the access path
Inspect both query plans. The baseline scans the table and sorts. Add one index for the recent-request list and one for complaint-category counts, then collect planner statistics with ANALYZE.
Step 03
Measure without changing the answer
Warm each query five times, then run 40 measurements per variant while alternating their execution order. Include fetching all rows in the elapsed time. Compare results across all 71 observed filter combinations; use a request identifier to break timestamp ties.
Step 04
Account for the cost
Record median and nearest-rank p95 latency, database bytes and raw timing samples. Count SQLite virtual-machine instructions in separate runs so the counting callback does not distort the latency measurements.
Findings
The evidence, and what it means.
01
Measured
The improvement has an explainable cause
For recent requests, the baseline plan reports a table scan and a temporary sort. The indexed plan uses a covering index: it can answer from the index itself. The separately measured instruction count falls from 208,717 to 361. The query and returned records are unchanged.[1][3][4]
Why it matters. This makes the result more useful than an isolated speed score: the access path explains which work was removed.
02
Measured
One index does not solve every dashboard query
The category-count query needs a different ordering of index columns. Its instructions fall from 231,257 to 42,881, but its plan still sorts the aggregated counts. The indexed median is 2.48 ms; we do not describe that remaining sort as eliminated.[1][3]
Why it matters. Index design follows individual access patterns. Adding indexes indiscriminately would hide storage and write costs.
03
Measured + interpretation
Speed is not a cloud saving
The database becomes 5,443,584 bytes larger. We did not measure insert throughput, production concurrency, CPU billing or an Azure invoice. A faster read is evidence of lower query work here; it is not evidence of a percentage reduction in operating cost.[1]
Why it matters. A cost recommendation needs the read/write mix, workload frequency and hosting measurements before resizing anything.
In detail
Inspect the results.
Recent requests
14.55 ms
Category counts
17.08 ms
Baseline: primary key only. Median of 40 warm runs per query.
Measured query latency on the saved workload
Query
Baseline median / p95
Indexed median / p95
Result check
Recent 50 requests
14.55 / 19.86 ms
0.52 / 0.68 ms
71 of 71 combinations match
Category counts
17.08 / 37.18 ms
2.48 / 3.78 ms
71 of 71 combinations match
40 warm measurements per query and variant. p95 is the 38th ordered observation, not a service-level objective. These are database-call timings on one machine, not website response times.[1]
SQL, timing rules and reproduction
The evidence download includes the exact source response, all raw timings, query plans and the analysis script. Run python scripts/analyze-public-studies.py from the extracted evidence folder. It uses Python’s standard library; SQLite versions are recorded in the output. Re-running refreshes local timing results, so compare the direction and query plans rather than expecting identical milliseconds.
SELECT unique_key, created_date, complaint_type
FROM requests
WHERE borough = ? AND agency = ?
ORDER BY created_date DESC, unique_key DESC
LIMIT 50;
CREATE INDEX requests_recent ON requests
(borough, agency, created_date DESC, unique_key DESC, complaint_type);
CREATE INDEX requests_categories ON requests
(borough, agency, complaint_type);
Recommendations · not deployed
What we would do next.
These are SystemVale’s recommendations for a comparable product or service. They are not claims that the organisations studied implemented them.
01
Apply the smallest useful change
Proposed for a comparable dashboard: capture its slow query and plan, add the narrowest index that supports the filter and ordering, and preserve a deterministic tie-breaker. Do not copy these indexes into a different schema without checking its actual access patterns.
02
Budget the writes and storage
Before rollout, measure insert/update latency, index build time and disk headroom on a realistic copy. If the workload is write-heavy or rarely uses the query, the additional index may not be worth keeping.
03
Validate the whole request
Repeat the measurement with the application, network and concurrent users included. On an Azure deployment, correlate query work with database CPU, request latency and provisioned capacity. Azure savings remain unmeasured in this study.
04
Make rollback explicit
Record the index definitions, deploy through the normal migration process, observe the agreed workload window, and remove the added indexes if write regressions outweigh read gains. Never change the result contract to improve a benchmark.
SystemVale’s conclusion
Improve the access path before buying more capacity, and carry correctness and storage into the same decision.
Our interpretation of this study. Not a client quote or endorsement.
Application
What this brings to your work.
01
Diagnose before scaling
Query plans expose unnecessary scans and sorts. They turn a general complaint about speed into a change that can be tested.
02
Keep the answer stable
Performance work is incomplete if faster queries return different rows, counts or ordering.
03
Measure the tradeoff
Read speed, write cost, storage and deployment risk belong together. A single latency number cannot settle the business decision.
One machine, one SQLite version, warm caches and no concurrent writers. Absolute timings will differ on other hardware.
Only two query shapes were timed. Correctness checks cover observed filter pairs, not every possible application query.
The 50,000-row sample is truncated and nonrandom. It is used only as a fixed engineering workload.
No live NYC system was changed. No customer experience, revenue or cloud-cost improvement was measured.
Reproduce the analysis
Download the five-study evidence bundle: captured public data, source hashes, scripts, licenses and original result files. The README explains the commands and the boundaries of each experiment.