Skip to content

Query language reads: PostgreSQL against the analytics store

Last updated: 2026-11-25T03:08:39-03:00 (UTC-3)

What the query language costs on each span engine (spans.engine: database or analytics_store): the forms it adds to the trace explorer, measured on the same data and by the same method as the explorer’s own reads.

  • OR, NOT and lists cost the same as a single term. A page of status:error OR fell_back:true or of a list with a negation answers in about 1 ms on PostgreSQL and 25 to 40 ms on the analytics store at 200,000 traces, like status:error alone.
  • A span field asked of traces, and child. terms, read the spans. guardrail.pii-in.outcome:masked, http_status>=500 and child.span.kind:tool child.status:ok take 7 to 9 ms a page on PostgreSQL and 22 to 32 ms on the analytics store; counting every match takes about 32 ms and 21 to 24 ms.
  • A facet of any field counts every matching row, like the built-in facets: 13 to 29 ms on PostgreSQL and 8 to 39 ms on the analytics store for 67 thousand traces or their spans.
  • In the spans scope, child. and parent. terms are the slowest form on the analytics store (49 to 66 ms a page); PostgreSQL answers them in 8 to 9 ms.

The choice of engine is the one the explorer’s page describes; the language does not change it.

Two reads are not in these tables because they are bounded by settings instead of growing with the data: an evaluation or feedback term, and a span field asked of the request log, name at most 2,000 traces or requests, and text search reads at most trace_query.text_search_max_records captured records (500 by default).

A probe in the gateway’s own test suite (internal/gateway/trace_query_probe_test.go, run only on request) writes the same generated traces to one engine through the gateway’s span writers, then times each read 20 times after one warm-up, through the functions the API calls. Both engines hold the same spans and answered the same row counts.

  • PostgreSQL 16 from the suite’s owned fixtures, with the span partitions and indexes the gateway creates; VACUUM (ANALYZE) after the load.
  • ClickHouse 25.12 in a container with the shipped config.xml and users.xml.
  • One Apple M4 Pro machine, the databases in local containers. The figures compare the two engines on the same data; they are not a capacity promise.

Every read covers the last 24 hours of a 72-hour window (a third of the traces) for readers of every team. Page is the first 50 rows; count is the facets read with its exact total; facet is the count of each value of one field.

The recorded runs are in query-language.json.

200,000 traces, 820,009 spans over 72 hours

Section titled “200,000 traces, 820,009 spans over 72 hours”
Read Rows matched or returned PostgreSQL p50 (ms) PostgreSQL p95 (ms) Analytics store p50 (ms) Analytics store p95 (ms)
Traces page: status:error 50 0.6 1.6 24.8 51.6
Traces page: status:error OR fell_back:true 50 0.8 2.2 24.6 32.4
Traces page: model:(chat-fast OR chat-large) -status:error duration>1s 50 1.4 1.7 37.9 66.5
Traces page: NOT (model:chat-fast OR fell_back:true) session:* 50 0.9 1.5 34.6 54.4
Traces page: guardrail.pii-in.outcome:masked (a span field) 50 7.5 8.8 32.3 124
Traces page: http_status>=500 (a span field) 50 8.2 10.0 22.5 29.3
Traces page: child.span.kind:tool child.status:ok (one span) 50 8.4 9.8 22.0 28.6
Traces page: child.span.kind:tool -fell_back:true model:chat-large 50 8.8 11.0 24.1 30.9
Traces count: status:error OR fell_back:true 5,278 15.4 19.4 25.5 46.7
Traces count: guardrail.pii-in.outcome:masked (a span field) 1,371 32.4 82.8 24.4 27.3
Traces count: child.span.kind:tool child.status:ok (one span) 6,636 31.8 69.7 20.9 23.7
Traces facet of valuation, every trace 66,666 12.6 13.5 18.7 27.7
Spans page: span.kind:provider_attempt (status:error OR duration>1500ms) 50 8.5 9.8 9.2 23.4
Spans page: span.kind:guardrail guardrail.flagged:true parent.span.kind:request 50 8.0 8.9 66.0 85.5
Spans page: span.kind:request child.span.kind:tool 50 9.1 10.4 48.8 66.7
Spans count: span.kind:provider_attempt (status:error OR duration>1500ms) 24,614 43.4 47.1 39.3 68.5
Spans facet of guardrail.pii-in.outcome, every span 66,666 28.8 34.4 38.7 73.2
Spans facet of provider, model:chat-fast OR model:chat-large 44,818 21.8 23.3 8.0 54.6

Writing the data took 11 s on PostgreSQL and 5 s on the analytics store; each read ran 20 times after one warm-up.

m7gtw[email protected]