发布

  • [OPIK-5150] [BE] perf: replace FINAL with ORDER BY/LIMIT 1 BY in optimization studio queries (#5738)

    frostbyte_neo 发布于 2026-03-19 13:44:53 +00:00

    • [OPIK-5150] [BE] perf: replace FINAL with ORDER BY/LIMIT 1 BY in experiment and optimization queries

    Replace ClickHouse FINAL modifier with explicit ORDER BY DESC + LIMIT 1 BY
    pattern across ExperimentDAO and OptimizationDAO queries for improved query
    performance in optimization studio.

    Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

    • fix: address PR review - two-layer dedup pattern, remove redundant LIMIT 1 BY, narrow SELECTs
    • Use dedup-then-filter subquery pattern: inner query deduplicates with
      immutable sort-key filters only, outer query applies mutable column
      filters (name, type, optimization_id, tags, etc.) to prevent phantom rows
    • Remove LIMIT 1 BY from feedback_scores/authored_feedback_scores CTEs
      (redundant with downstream ROW_NUMBER, and missing author key would
      drop authored scores)
    • Narrow SELECT * to specific columns in spans and experiment_aggregates
      helper CTEs where only a few columns flow downstream

    Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


    Co-authored-by: Claude Opus 4.6 noreply@anthropic.com

    下载附件