1EXPLAIN SELECT
2 host,
3 count(DISTINCT ip_address) as host_count
4FROM analytics_visits
5WHERE user_id = '2c182b8f-ad65-4543-8ac9-2c47bb20172d' AND host <> '' AND status >= 200 AND status < 300
6GROUP BY host
7ORDER BY host_count DESC;
8 QUERY PLAN
9---------------------------------------------------------------------------------------------------------------------
10 Sort (cost=277960.43..277960.75 rows=128 width=23)
11 Sort Key: (count(DISTINCT ip_address)) DESC
12 -> GroupAggregate (cost=272617.22..277955.95 rows=128 width=23)
13 Group Key: host
14 -> Sort (cost=272617.22..274396.37 rows=711660 width=79)
15 Sort Key: host
16 -> Bitmap Heap Scan on analytics_visits (cost=10039.64..171818.42 rows=711660 width=79)
17 Recheck Cond: (user_id = '2c182b8f-ad65-4543-8ac9-2c47bb20172d'::uuid)
18 Filter: (((host)::text <> ''::text) AND (status >= 200) AND (status < 300))
19 -> Bitmap Index Scan on analytics_visits_user_id_idx (cost=0.00..9861.73 rows=876439 width=0)
20 Index Cond: (user_id = '2c182b8f-ad65-4543-8ac9-2c47bb20172d'::uuid)
21 JIT:
22 Functions: 11
23 Options: Inlining false, Optimization false, Expressions true, Deforming true
24(14 rows)