The get_sources_size query is very slow, so speed up the first part of it (finding the most recent backups, by host) with an index.