mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-06 00:09:22 +00:00
## 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>