Conversation
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/7bb628cb-282d-44c3-b912-9c81212611a9 Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add indices on roms and rom_files for improved performance
Add missing index on Apr 14, 2026
rom_files(rom_id) to fix slow game listing on large ROM sets
gantoine
approved these changes
Apr 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an explicit DB index on rom_files.rom_id to eliminate slow sequential scans when joining rom_files to roms for large libraries, improving game listing performance.
Changes:
- Add SQLAlchemy model-level index
idx_rom_files_rom_idonRomFile.rom_id. - Add Alembic migration to create/drop the same index on existing databases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/models/rom.py | Defines idx_rom_files_rom_id on rom_files(rom_id) at the ORM/schema level. |
| backend/alembic/versions/0079_add_rom_files_rom_id_index.py | Creates the rom_files(rom_id) index for existing installations (with downgrade). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Test Results (mariadb)1 243 tests 1 243 ✅ 3m 50s ⏱️ Results for commit ce5624b. |
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Contributor
Test Results (postgresql)1 243 tests 1 243 ✅ 3m 52s ⏱️ Results for commit ce5624b. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On large libraries (60k+ ROMs), listing games per platform was taking 4500ms+ due to a sequential scan on
rom_fileswhen joining toroms. The FK columnrom_files.rom_idhad no index — only the PKidwas indexed.Note:
roms(platform_id)is already covered by the existing composite indexidx_roms_platform_id_fs_name(leftmost-prefix).Changes
models/rom.py— Added__table_args__toRomFilewithidx_rom_files_rom_idindex onrom_idalembic/versions/0079_add_rom_files_rom_id_index.py— Migration to create the index on existing databases