CollectionStatistics: prefetch all stats on start
When Akonadi is started each application and agent starts requesting its Collections and statistics. This causes the CollectionStatistics cache to query the stats for each Collection individually with the very expensive query. On my system all the statistics queries together take over 17 seconds. With this change the CollectionStatistics cache simply pre-fetches statistics for all Collections in single a query, which is MUCH faster (less than a second on my system), because the expensive JOINs only have to be done once. As a result of this change applications and agents become responsive much faster after start and CPU and IO load during start is massively decreased.
Showing with 119 additions and 8 deletions