发布

  • [OPIK-7319] Optimize getTraceKpiCards: drop trace_costs LEFT JOIN (#7452)

    frostbyte_neo 发布于 2026-07-13 16:29:42 +00:00

    • [OPIK-7319] Optimize getTraceKpiCards: drop trace_costs LEFT JOIN

    Pre-aggregate the TOTAL_COST KPI into current/previous buckets inside
    trace_costs (keyed on trace_id, the same UUIDv7 used for the
    count/error/duration split) and CROSS JOIN it as a single row, instead
    of a per-trace LEFT JOIN against traces_filtered whose hash build
    dominated peak memory on large projects. Results are identical; the
    trace_id IN (traces_filtered) semijoin is retained for correctness.

    Validated on prod (worst project, ~14d window): identical output, median
    latency 2971->2552ms (~14%), median peak memory 1.54->1.23 GiB (~20%),
    IO unchanged.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • [OPIK-7319] Add trace multi-span cost regression test

    Pins the trace_costs behaviour the rewrite depends on: a trace's
    TOTAL_COST is the sum of all its spans, and the CROSS JOIN does not
    scale cost by the number of traces. Complements the existing
    parameterized both-periods/current/previous/no-data/filter coverage.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件