发布

  • [OPIK-7197] fix: avoid materializing wide internal temp tables in prompt/dataset version lookups (#7328)

    frostbyte_neo 发布于 2026-07-03 08:04:54 +00:00

    PromptVersionDAO.find wrapped SELECT pv.* (large TEXT/JSON columns) in a
    'paginated' CTE referenced twice, forcing MySQL to materialize a wide internal
    temp table. Under load the TempTable RAM+mmap pools saturate and MySQL throws
    "Table '/rdsdbdata/tmp/#sql...' doesn't exist" (surfaced as SQLSyntaxErrorException).
    Rewrite as a flat query with environments via an indexed correlated subquery.

    DatasetVersionDAO.findByTag had the same anti-pattern via a version_sequences
    CTE referenced twice; rewrite version_name/tags/is_latest via correlated
    subqueries. Both verified result-identical and temp-table-free via EXPLAIN ANALYZE.

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

    下载附件