optimize searching for files... takes 300s query down to 15s.
SQLite3 does not do joins in a sane manner, so we emulate them
w/ subqueries for a large boost. Not sure if adding distinct would
improve things or not, the query plan does not change between the
two (but the lower ops may), but in a quick test, it didn't seem
to make a difference (not evaluated statistically)...