explain.depesz.com

PostgreSQL's explain analyze made readable

Result: q7q : Getting count of distinct elements, per group, in PostgreSQL - First, Reduce The Data Set

Settings
# exclusive inclusive rows x rows loops node
1. 0.233 4,596.837 ↓ 4.7 946 1

Sort (cost=326,982.89..326,983.39 rows=200 width=23) (actual time=4,596.780..4,596.837 rows=946 loops=1)

  • Sort Key: (count(1))
  • Sort Method: quicksort Memory: 98kB
2. 0.341 4,596.604 ↓ 4.7 946 1

Hash Join (cost=326,968.50..326,975.25 rows=200 width=23) (actual time=4,596.151..4,596.604 rows=946 loops=1)

  • Hash Cond: (time_on_site_logs.dashboard_id = dashboards.id)
3. 0.553 4,595.889 ↓ 4.7 946 1

HashAggregate (cost=326,931.50..326,933.50 rows=200 width=4) (actual time=4,595.765..4,595.889 rows=946 loops=1)

  • Group Key: time_on_site_logs.dashboard_id
4. 2,636.571 4,595.336 ↑ 5.6 1,700 1

HashAggregate (cost=326,695.00..326,789.60 rows=9,460 width=8) (actual time=4,595.128..4,595.336 rows=1,700 loops=1)

  • Group Key: time_on_site_logs.dashboard_id, time_on_site_logs.user_id
5. 1,958.765 1,958.765 ↑ 1.0 14,001,200 1

Seq Scan on time_on_site_logs (cost=0.00..256,689.00 rows=14,001,200 width=8) (actual time=0.187..1,958.765 rows=14,001,200 loops=1)

6. 0.217 0.374 ↑ 1.0 1,200 1

Hash (cost=22.00..22.00 rows=1,200 width=19) (actual time=0.374..0.374 rows=1,200 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 61kB
7. 0.157 0.157 ↑ 1.0 1,200 1

Seq Scan on dashboards (cost=0.00..22.00 rows=1,200 width=19) (actual time=0.007..0.157 rows=1,200 loops=1)

Total runtime : 4,596.934 ms