mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
`idx_roms_sibling_cover` (0090) was built for the sibling_roms self-join, but
the group_by_meta_id dedup window in `filter_roms` reads the same shape plus
two columns the index does not carry: `flashpoint_id`, the tail of the
partition's COALESCE chain, and `fs_name_no_ext`, the tiebreaker each partition
sorts by. A covering index has to carry every referenced column, so those two
omissions dropped the window to a full scan of the wide roms row -- JSON
metadata blobs included -- and the gallery runs that window up to four times
per page load (page, count, char_index, rom_id_index).
Grouping is on by default, so this is the default path for every large library.
Measured on a 92.8k-rom MariaDB copy (963 MB roms table, 256 MB buffer pool)
with the queries the endpoint actually generates:
page of 72 5.43s -> 0.80s
count 5.55s -> 1.01s
rom_id_index 5.48s -> 1.10s
char_index 5.46s -> 1.06s
combined 21.93s -> 3.97s
EXPLAIN moves from `type=ALL, key=NULL` to `type=index, Using index`. Real
`fs_name_no_ext` values are far shorter than the column's varchar(450), so the
index grows 4 MB -> 7 MB and rebuilds in ~5s at that row count.
The wider index costs the sibling_roms join ~170ms -> ~209ms per 72-rom page.
Keeping the narrow index alongside a second dedup-only one recovers that, but
the two would share their first eight columns and the per-page totals came out
level (2.13s vs 2.12s), so a single index wins on write amplification and stops
the two consumers drifting apart again.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>