sampsyo/beets — pull request #1106 by greenpart (2014-11-21 01:07:31+00:00)
Title: Identity map to avoid some redundant queries/materialization

Identity maps in `dbcore` lets reuse materialized objects. Two calls for `db._get(Model, id)` will invoke only one database query and only one object materialization. `load()' and 'remove()' handled too.

With this patch `beets` asks once for each album when listing tracks.
On my library with around 6K tracks i got results listed below.

query (>/dev/null)|speedup
---|:---:
`beet ls`|27%
`beet ls beatles`|4%
`beet ls bpm:110..130`|11%
_from cookbook_|
`beet ls bitrate:128000`|13%
`beet ls -f '$bitrate $artist - $title'`|35%