beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.92k stars 1.82k forks source link

Fixup: use fast queries for fields shared between albums and items tables #5385

Closed snejus closed 3 months ago

snejus commented 3 months ago

I surprisingly found that many queries for fields that exist in the database are 'slow'. Querying items with month:0 used a slow query while title:0 used a fast one.

I found the mistake in the logic: the field existence in the db check was done after prepending the table name to the field. This meant that the logic wrongly checked e.g. items.field instead of field.

This commit fixes the above and renames the variables for more clarity.

github-actions[bot] commented 3 months ago

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Serene-Arc commented 3 months ago

Merge when ready, unless you want another review @snejus

Serene-Arc commented 3 months ago

btw again, great catch. It took me like 5 different readings to get what changed in that code lol

snejus commented 3 months ago

btw again, great catch. It took me like 5 different readings to get what changed in that code lol

Sounds like the code should be improved regarding its readability 😆