How to Calculate Multiple Aggregate Functions in a Single Query
https://blog.jooq.org/2017/04/20/how-to-calculate-multiple-aggregate-functions-in-a-single-query/ [blog.jooq.org]
2017-04-23 17:14
In the end, there were 32 queries in total (or 8 in my example) with all the possible combinations of predicates. Needless to say that running them all took quite a while, because the table had around 200M records and only one predicate could profit from an index.
But in fact, the improvement is really easy. There are several options to calculate all these counts in a single query
source: L