explain.depesz.com

PostgreSQL's explain analyze made readable

Result: CCAk : Getting count of distinct elements, per group, in PostgreSQL - Aggregate, Then Join

Settings
# exclusive inclusive rows x rows loops node
1. 0.769 23,124.770 ↑ 1.0 946 1

Sort (cost=2,597,965.92..2,597,968.29 rows=946 width=23) (actual time=23,124.698..23,124.770 rows=946 loops=1)

  • Sort Key: (count(DISTINCT time_on_site_logs.user_id))
  • Sort Method: quicksort Memory: 98kB
2. 1.239 23,124.001 ↑ 1.0 946 1

Hash Join (cost=2,492,878.23..2,597,919.16 rows=946 width=23) (actual time=18,235.838..23,124.001 rows=946 loops=1)

  • Hash Cond: (time_on_site_logs.dashboard_id = dashboards.id)
3. 2,336.820 23,122.119 ↑ 1.0 946 1

GroupAggregate (cost=2,492,841.23..2,597,859.69 rows=946 width=8) (actual time=18,235.182..23,122.119 rows=946 loops=1)

  • Group Key: time_on_site_logs.dashboard_id
4. 18,719.425 20,785.299 ↑ 1.0 14,001,200 1

Sort (cost=2,492,841.23..2,527,844.23 rows=14,001,200 width=8) (actual time=18,232.615..20,785.299 rows=14,001,200 loops=1)

  • Sort Key: time_on_site_logs.dashboard_id
  • Sort Method: external merge Disk: 246376kB
5. 2,065.874 2,065.874 ↑ 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.223..2,065.874 rows=14,001,200 loops=1)

6. 0.354 0.643 ↑ 1.0 1,200 1

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

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

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

Total runtime : 23,165.649 ms