Reduce the number of queries for attachment files.

Currently we’re doing 2 queries for each file, while we can easily
fetch the current revision in one query. MySQL will likewise be able to
cache that.