Files
romm/backend
Spinnich 60eb455fe8 perf(roms): cover the sibling dedup window with its index
`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>
2026-08-01 19:35:23 +00:00
..
2026-06-21 17:42:25 -04:00
2026-07-01 08:58:00 -04:00
2024-02-10 12:43:39 -05:00
2025-07-05 19:17:40 -04:00
2026-07-26 15:16:56 -04:00
2026-05-17 17:39:47 -04:00
2026-05-22 22:35:30 -04:00