lehitoskin/ivy

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

Closed this issue · 2 comments

This is from the release notes for v2.1.1.

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.

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".