Entity queries have the allRevisions() option. This allows us to do a single query instead of batching entity ids, and then querying for every revision of each of them. This will save a lot of queries.
Active
2.0
Code