Files
openobserve/src
a2097e13f0 fix: merge Q2a per-trace aggregates into Q1 to eliminate redundant search call (#12616)
## Summary

Eliminates 1 of 3 redundant \SearchService::cache::search\ calls per
trace request by merging the Q2a (per-trace aggregate fields) SQL
directly into Q1.

### Changes

- **\uild_llm_trace_query\**: Added \extra_selects: &str\ param — Q2a
fields injected before \FROM\ for both regular and LLM trace queries
- **\get_latest_traces\**: Moved schema-dependent expression computation
before Q1 SQL building; extended Q1 with Q2a columns (span_count,
error_count, max_duration, service_count, root_service_name,
first_service_name, first_operation_name); removed entire Q2a search
block (~200 lines)
- **\process_latest_traces_stream\**: Same Q1 extension; added
early-break after 3 consecutive empty partitions for absolute time
ranges
- **\ un_q2_for_traces\**: Removed Q2a search call; populates all fields
directly from Q1 hits; keeps Q2b (service breakdown) for multi-service
traces

### Before (3 search calls per request)

1. Q1 — basic trace list
2. Q2a — \	race_id IN (...)\ for span aggregates (removed)
3. Q2b — \	race_id IN (...)\ for service breakdown

### After (2 search calls, or 1 for single-service traces)

1. Q1 — trace list with all aggregates
2. Q2b — service breakdown (multi-service only)

### Risk

Low. The removed Q2a code was entirely internal — column aliases like
\min_start_time\/\max_end_time\ had zero external references.
\TraceResponseItem\ struct unchanged. All fields now populated from Q1
with equivalent values.

---------

Co-authored-by: Giriraj Bidwai <girirajbidwai@users.noreply.github.com>
Co-authored-by: Hengfei Yang <hengfei.yang@gmail.com>
2026-06-22 06:03:31 +00:00
..
2026-06-18 04:25:21 +00:00
2026-06-02 03:58:01 +00:00
2026-05-04 10:38:41 +00:00
2026-06-02 03:58:01 +00:00
2026-06-22 05:11:57 +00:00