In looking at the code I noticed that the index on the “path” column is not added until the end of all the scanning. I realize there is some “insert” pain for an index, but in this case I can’t imagine that it would exceed the pain of a non-indexed select. Perhaps making this some sort of startup option, such that people with small memory can take the index hit to prevent swapping on the search.
There are two code paths, one for a “from scratch” scan, when the db is empty, and the other for when there are already songs in the db. When there are no songs in the db, I don’t build the index until it is scanned, but it shouldn’t matter, as selects should return not found immediately, without querying the db.
Actually, it sounds like you lost your indexes, because if you are doing an incremental scan it should already have its indexes.
Do a mt-daapd -r to force a new full scan, and it should rebuild indexes fine. I’m going to add defensive code to make sure that the indexes already exist when doing an incremental scan, but that will probably help your startup time.