mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
Ordering the gallery by a `roms_metadata` field joined the view back in and sorted through it. `roms_metadata` is a thin view over STORED generated columns on `roms` (migration 0098), so that join is `roms` to itself and it leaves the sort key on a joined table, which no index can serve: the engine filesorts the whole library for every page. The generated columns are already indexed, so the three that are offered as sorts now resolve straight to them and the join goes away. On a 120k-row table this turns a full scan plus filesort into a 72-row index walk. The remaining view columns are JSON arrays with no index and no sort that offers them, so they keep reading the view. Fixes #4067 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>