-
[OPIK-6482] [BE] fix: add (workspace_id, scope, id) index on dashboards to avoid filesort OOM (#6733)
发布于
2026-05-18 10:52:03 +00:00 - [OPIK-6482] [BE] fix: add (workspace_id, scope, id) index on dashboards to satisfy ORDER BY from index and avoid filesort OOM
The list-dashboards query
SELECT * FROM dashboards WHERE workspace_id = ? AND scope = ? ORDER BY id DESC LIMIT ? OFFSET ?
falls back to filesort because no index covers both the equality filter and the ORDER BY key. With SELECT *
including the JSONconfigcolumn, the filesort step copies the full row into the sort buffer, and Aurora
MySQL 8.0 raises ER_OUT_OF_SORTMEMORY (errno 1038) even at LIMIT=1 due to JSON addon-field sizing in the sort
buffer. Observed in Netflix opik state DB: 168 failed calls between 2026-05-02 and 2026-05-12, surfacing as
500s for the affected workspace.Adding (workspace_id, scope, id) lets the optimizer satisfy the equality + ORDER BY id DESC from index order
via a backward index scan, eliminating the filesort step entirely. The JSON column is still selected but is
never copied into a sort buffer.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
- [OPIK-6482] [BE] address review: bump migration to 000070 and add trailing blank line
- Bump 000069 -> 000070 (000069 was taken by add_has_legacy_scores_to_workspaces after this branch was opened)
- Add trailing blank line per Liquibase migration convention
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com
下载附件