Skip to content

Add support for creating indices on arbitrary database tables #5926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

semohr
Copy link
Contributor

@semohr semohr commented Aug 10, 2025

Creating indexes turned out to be relatively straightforward!
While we can’t remove them yet, that doesn’t seem necessary for now. Interestingly, much of the infrastructure for database additions was already in place.

  • This PR introduces a new type, Index, which can be used to create an index on any defined table. 🎉
  • The items table now automatically registers an index on album_id

Closes #5809

@Copilot Copilot AI review requested due to automatic review settings August 10, 2025 21:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for creating database indices on arbitrary tables to improve query performance. The implementation introduces a new Index type and applies it to create an index on the album_id column of the items table.

  • Introduces a new Index type for defining database indices
  • Adds infrastructure to automatically create indices during table setup
  • Creates an index on album_id for the items table to speed up album-based queries

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
docs/changelog.rst Documents the new index creation for album_id queries
beets/library/models.py Adds index definition to the Item model
beets/dbcore/types.py Defines the new Index type
beets/dbcore/db.py Implements index creation logic in database setup

@semohr semohr changed the title "Add support for creating indices on arbitrary database tables Add support for creating indices on arbitrary database tables Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Indexes in SQLite Database Causing Performance Bottlenecks
1 participant