lehitoskin / ivy

Ivy, the Taggable Image Viewer
GNU General Public License v3.0
16 stars 3 forks source link

Sorting by rating in collections that contain many images may take a long time #55

Closed IonoclastBrigham closed 7 years ago

IonoclastBrigham commented 7 years ago

This is from the release notes for v2.1.1.

IonoclastBrigham commented 7 years ago

Is the code pulling the alphabetical results, and then re-sorting the list by rating? It might be faster to re-query the DB with appropriate ORDERBY and ASC/DESC clauses.

lehitoskin commented 7 years ago

It's not querying the DB at all, which is why it's so slow. It accesses each file and checks its rating (those not rated are defaulted to "0"). I was considering adding the rating to the DB, but that would possibly break for older versions of the database. Now that you mention it, however, it does seem a little silly to check every file's metadata for the xmp:Rating when it would be much, much faster to query the database on sorting. I'll just have to add something like "if DB has no RATING entry for PATH, return 0".