Trace explorer reads: PostgreSQL against the analytics store
Last updated: 2026-11-24T18:27:56-03:00 (UTC-3)
How long the trace explorer takes to answer on each span engine (spans.engine: database or analytics_store, see span store engines for the write side), with the same traces in both.
Which one to choose
Section titled “Which one to choose”Neither engine is slow for the explorer; they are fast at different things.
- Lists of traces and opening a trace are fastest on PostgreSQL: 1 to 5 ms for a page at a million traces, under a millisecond for a trace. A page reads the newest hour first, so it does not grow with the time range. The analytics store answers the same pages in 15 to 60 ms, because a trace’s summary there is the sum of the rows each write added.
- Counting is fastest on the analytics store: the facet rail with its exact total, and the count over time, take 20 to 100 ms there whatever the range. PostgreSQL counts every row of the range: 80 to 260 ms for 67 to 270 thousand rows, 0.4 to 1.6 s for 0.3 to 1.4 million. The facets load beside the list, so the list is on screen first either way.
- The figures and the chart follow the same rule: the percentiles, tokens and cost of a query, and one metric by one breakdown, read every matching row. The analytics store answers them in 7 to 130 ms at any size measured; PostgreSQL in 30 to 100 ms for up to 270 thousand rows and 0.2 to 0.7 s for 0.3 to 1.4 million. The figures are one more aggregate in the facets read; the chart is read only when a metric or a breakdown is chosen.
- Lists of spans take 12 ms on PostgreSQL at 820 thousand spans and 50 to 75 ms at 4.1 million; the analytics store stays near 10 ms.
So: the database is enough while the time ranges your readers open hold up to a few hundred thousand spans (a day of a deployment serving a few requests per second), and it gives the fastest lists. Choose the analytics store when a time range holds millions of spans and readers use the facets and totals a lot, or when you already chose it for the write side (span store engines).
Readers of one team see the same shape: the team filter is part of the same read.
Method
Section titled “Method”A probe in the gateway’s own test suite (internal/gateway/trace_explorer_probe_test.go, run only on request) writes the same generated traces to one engine through the gateway’s span writers, then times each explorer read 20 times after one warm-up, in process, through the same functions the API calls. A trace is one chat request with its routing, guardrail and provider attempt spans, a tool call in one of ten, across four teams and six models, 3% in error, 5% with a fallback, spread evenly over 72 hours; “24 h” is therefore a third of the data and “7 d” all of it.
- PostgreSQL 16 from the suite’s owned fixtures, with the span partitions and indexes the gateway creates;
VACUUM (ANALYZE)after the load, as on a database that has been running. - ClickHouse 25.12 in a container with the shipped
config.xmlandusers.xml(thegatewayuser and its grants, nothing more). - One Apple M4 Pro machine, the databases in local containers, nothing else under load. The figures are for comparing the two engines on the same data, not a capacity promise.
The recorded runs are in trace-explorer.json.
200,000 traces, 820,002 spans over 72 hours
Section titled “200,000 traces, 820,002 spans over 72 hours”| Read | Rows matched or returned | PostgreSQL p50 (ms) | PostgreSQL p95 (ms) | Analytics store p50 (ms) | Analytics store p95 (ms) |
|---|---|---|---|---|---|
| Traces: first page, 24 h, every team | 50 | 1.1 | 1.4 | 16.4 | 19.2 |
| Traces: second page by cursor, 24 h | 50 | 1.2 | 1.4 | 17.1 | 19.6 |
| Traces: first page, 24 h, one team | 50 | 2.7 | 3.1 | 14.5 | 18.4 |
| Traces: status:error, 24 h | 50 | 0.7 | 1.1 | 16.5 | 22.5 |
| Traces: model and duration>2s, 24 h | 50 | 1.0 | 1.1 | 20.8 | 27.2 |
| Traces: first page, 7 d (all data) | 50 | 1.3 | 2.0 | 17.3 | 21.0 |
| Traces: status:error, 7 d (all data) | 50 | 0.6 | 0.7 | 17.8 | 20.3 |
| Traces: one trace by ID, 7 d | 1 | 15.0 | 27.8 | 6.0 | 6.7 |
| Spans: first page, 24 h | 50 | 12.3 | 15.2 | 6.0 | 8.1 |
| Spans: model calls in error, 24 h | 50 | 11.4 | 12.4 | 6.4 | 7.4 |
| Spans: first page, 7 d (all data) | 50 | 13.0 | 13.5 | 7.5 | 8.9 |
| Facets: traces, 24 h | 66,666 | 77.6 | 2,809 | 20.6 | 36.7 |
| Facets: traces, 7 d (all data) | 200,000 | 233 | 235 | 25.1 | 26.9 |
| Facets: spans, 24 h | 273,221 | 260 | 419 | 47.7 | 53.6 |
| Histogram: traces, 24 h | 25 | 19.7 | 20.9 | 12.5 | 15.6 |
| Figures: traces, 24 h | 66,666 | 27.1 | 28.7 | 21.8 | 37.1 |
| Figures: traces, 7 d (all data) | 200,000 | 98.8 | 101 | 30.2 | 31.8 |
| Figures: spans, 24 h | 273,221 | 85.9 | 88.1 | 18.3 | 21.2 |
| Chart: traces, count by model, 24 h | 66,666 | 35.2 | 43.8 | 19.5 | 22.5 |
| Chart: traces, cost by team, 7 d (all data) | 200,000 | 82.6 | 86.2 | 20.5 | 28.0 |
| Chart: spans, mean duration by status, 24 h | 273,221 | 56.7 | 121 | 6.8 | 12.4 |
| Detail: one trace with its summary | 4 | 0.7 | 1.6 | 6.6 | 7.5 |
| Detail: the Logs tab’s records | 0 | 0.4 | 0.5 | 0.4 | 0.9 |
Writing the data took 14 s on PostgreSQL and 3 s on the analytics store; each read ran 20 times after one warm-up.
1,000,000 traces, 4,099,973 spans over 72 hours
Section titled “1,000,000 traces, 4,099,973 spans over 72 hours”| Read | Rows matched or returned | PostgreSQL p50 (ms) | PostgreSQL p95 (ms) | Analytics store p50 (ms) | Analytics store p95 (ms) |
|---|---|---|---|---|---|
| Traces: first page, 24 h, every team | 50 | 4.9 | 5.2 | 41.0 | 55.1 |
| Traces: second page by cursor, 24 h | 50 | 5.1 | 5.4 | 41.7 | 45.7 |
| Traces: first page, 24 h, one team | 50 | 2.4 | 15.7 | 36.5 | 41.3 |
| Traces: status:error, 24 h | 50 | 1.8 | 2.3 | 43.0 | 60.4 |
| Traces: model and duration>2s, 24 h | 50 | 3.2 | 3.5 | 62.3 | 71.2 |
| Traces: first page, 7 d (all data) | 50 | 4.9 | 5.6 | 46.4 | 58.2 |
| Traces: status:error, 7 d (all data) | 50 | 1.6 | 1.8 | 46.5 | 51.0 |
| Traces: one trace by ID, 7 d | 1 | 123 | 251 | 7.1 | 7.7 |
| Spans: first page, 24 h | 50 | 57.4 | 72.2 | 11.1 | 12.5 |
| Spans: model calls in error, 24 h | 50 | 50.7 | 57.3 | 12.5 | 14.4 |
| Spans: first page, 7 d (all data) | 50 | 61.9 | 101 | 16.3 | 19.8 |
| Facets: traces, 24 h | 333,333 | 411 | 485 | 69.6 | 94.0 |
| Facets: traces, 7 d (all data) | 1,000,000 | 1,326 | 1,370 | 91.7 | 102 |
| Facets: spans, 24 h | 1,366,458 | 1,562 | 1,772 | 67.0 | 80.0 |
| Histogram: traces, 24 h | 25 | 99.0 | 133 | 37.2 | 42.8 |
| Figures: traces, 24 h | 333,333 | 168 | 175 | 73.4 | 87.5 |
| Figures: traces, 7 d (all data) | 1,000,000 | 679 | 699 | 129 | 145 |
| Figures: spans, 24 h | 1,366,458 | 666 | 711 | 58.5 | 61.7 |
| Chart: traces, count by model, 24 h | 333,333 | 192 | 209 | 53.5 | 60.8 |
| Chart: traces, cost by team, 7 d (all data) | 1,000,000 | 552 | 560 | 58.3 | 69.8 |
| Chart: spans, mean duration by status, 24 h | 1,366,458 | 346 | 365 | 9.9 | 15.6 |
| Detail: one trace with its summary | 4 | 0.6 | 1.7 | 7.2 | 8.4 |
| Detail: the Logs tab’s records | 0 | 0.3 | 0.5 | 0.4 | 0.7 |
Writing the data took 66 s on PostgreSQL and 20 s on the analytics store; each read ran 20 times after one warm-up.
Reading the tables
Section titled “Reading the tables”- First page is the list as the screen opens it: 50 rows, newest first. Second page continues with the cursor.
- Facets is the facet rail with the exact total; it counts every matching row, so on PostgreSQL it grows with the range.
- One trace by ID is the query
trace_id:<id>in the list; one trace with its summary is opening the detail. - Figures is the facets read’s
stats=true: count, discrete percentiles and mean of the duration, tokens, errors and cost. Chart isGET /traces/chart: one metric by one breakdown over time. - A p95 far above its p50 on PostgreSQL (2.8 s once, at 200,000 traces) is a single read that waited on the database’s own background work after the bulk load; the other 19 runs of that read are at the p50.
- The Logs tab’s records are read from PostgreSQL on both engines (the request log and the ledger live there); the generated traces have no request log rows, so that line is the cost of the empty reads.