Most of the time is indeed spent computing counts; Unfortunately I think Abel's work on StormRangeFactory cannot be applied to this because of the limitations it has (namely, that resultsets must be entire objects: simply adding range_factory = StormRangeFactory(results) fails to create a proper explain query: "EXPLAIN SELECT Branch.date_last_modified DESC, Branch.target [...]"). Maybe the query could be refactored to make it work but the way the query is built is rather complex.
I'll see if I can find a way to improve the queries themselves (for instance by caching the result of the subquery https://pastebin.canonical.com/54940/ which is repeated over and over).
Most of the time is indeed spent computing counts; Unfortunately I think Abel's work on StormRangeFactory cannot be applied to this because of the limitations it has (namely, that resultsets must be entire objects: simply adding range_factory = StormRangeFacto ry(results) fails to create a proper explain query: "EXPLAIN SELECT Branch. date_last_ modified DESC, Branch.target [...]"). Maybe the query could be refactored to make it work but the way the query is built is rather complex.
I'll see if I can find a way to improve the queries themselves (for instance by caching the result of the subquery https:/ /pastebin. canonical. com/54940/ which is repeated over and over).