-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
beet list -a path:some/path queries are extremely slow #4360
Comments
I added a
Seems like it initially gets all albums, then loops across them and hits the db to get its items. Added a conditional raise in the same function in order to see the calls that lead to the first one of if "FROM items" in sql and "album_id" in query.field:
raise Exception items MatchQuery('album_id', 7222, True)
Traceback (most recent call last):
File "/home/sarunas/.local/bin/beetbin", line 5, in <module>
main()
File "/home/sarunas/repo/beets/beets/ui/__init__.py", line 1304, in main
_raw_main(args)
File "/home/sarunas/repo/beets/beets/ui/__init__.py", line 1291, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/home/sarunas/repo/beets/beets/ui/commands.py", line 1089, in list_func
list_items(lib, decargs(args), opts.album)
File "/home/sarunas/repo/beets/beets/ui/commands.py", line 1081, in list_items
for album in lib.albums(query):
File "/home/sarunas/repo/beets/beets/dbcore/db.py", line 714, in _get_objects
if not self.query or self.query.match(obj):
File "/home/sarunas/repo/beets/beets/dbcore/query.py", line 463, in match
return all(q.match(item) for q in self.subqueries)
File "/home/sarunas/repo/beets/beets/dbcore/query.py", line 463, in <genexpr>
return all(q.match(item) for q in self.subqueries)
File "/home/sarunas/repo/beets/beets/dbcore/query.py", line 119, in match
return self.value_match(self.pattern, item.get(self.field))
File "/home/sarunas/repo/beets/beets/dbcore/db.py", line 371, in _get
return getters[key](self)
File "/home/sarunas/repo/beets/beets/library.py", line 1254, in item_dir
item = self.items().get()
File "/home/sarunas/repo/beets/beets/library.py", line 1149, in items
return self._db.items(dbcore.MatchQuery('album_id', self.id))
File "/home/sarunas/repo/beets/beets/library.py", line 1555, in items
return self._fetch(Item, query, sort or self.get_default_item_sort())
File "/home/sarunas/repo/beets/beets/library.py", line 1533, in _fetch
return super()._fetch(
File "/home/sarunas/repo/beets/beets/dbcore/db.py", line 1081, in _fetch
raise Exception
Exception Since the query filters on the Initial thoughts on how this could be improved:
This should in turn
|
Indeed; the big shortcoming here is that we can't generate proper |
I've just opened a pull request which contains an update on query composition, which (I think) does not cause a big change in the overall architecture. |
Problem
beet list -a path:
seems to be much, much slower thanbeet list path:
while in reality an album query should be at least a tiny bit faster than an item query since there are fewer entities in the table.Running a path query for items:
Running the same query for albums:
And querying albums for a path that does not exist:
Note:
count
is a shell function which measures the timing of the supplied commandSeeing that the last query took so long even though the result is empty, I have a feeling it's caused by some initial query returning all items/albums from the database, where filtering is done in python by looping across the items (potentially making additional queries, - seeing that this operation is really slow).
FYI, probably related, that's my
beet stats
output:Setup
master
branch, 988bf26The text was updated successfully, but these errors were encountered: