explain.depesz.com

PostgreSQL's explain analyze made readable

Result: J9cE

Settings
# exclusive inclusive rows x rows loops node
1. 0.094 7,429.115 ↑ 111.3 7 1

GroupAggregate (cost=260,037.05..266,430.52 rows=779 width=12) (actual time=7,429.012..7,429.115 rows=7 loops=1)

  • Group Key: workplaces.clinic_id
2. 0.182 7,429.021 ↑ 15,767.1 54 1

Sort (cost=260,037.05..262,165.61 rows=851,424 width=8) (actual time=7,428.978..7,429.021 rows=54 loops=1)

  • Sort Key: workplaces.clinic_id
  • Sort Method: quicksort Memory: 27kB
3. 660.346 7,428.839 ↑ 15,767.1 54 1

Hash Join (cost=611.70..164,532.84 rows=851,424 width=8) (actual time=6,072.617..7,428.839 rows=54 loops=1)

  • Hash Cond: (workplaces.clinic_id = clinics.id)
4. 1,588.381 6,760.953 ↑ 1.4 601,289 1

Hash Join (cost=390.35..162,058.56 rows=853,616 width=8) (actual time=17.462..6,760.953 rows=601,289 loops=1)

  • Hash Cond: (events.workplace_id = workplaces.id)
5. 5,155.299 5,155.299 ↑ 1.6 633,192 1

Index Scan using index_events_on_ended_at on events (cost=0.43..158,939.28 rows=1,039,317 width=12) (actual time=0.105..5,155.299 rows=633,192 loops=1)

  • Index Cond: ((ended_at >= '2020-01-01 00:00:00'::timestamp without time zone) AND (ended_at <= '2020-07-06 00:00:00'::timestamp without time zone))
  • Filter: ((deleted_at IS NULL) AND (NOT absent) AND (confirmed_at IS NULL) AND (canceled_at IS NULL))
  • Rows Removed by Filter: 1,891,158
6. 7.532 17.273 ↓ 1.0 8,158 1

Hash (cost=288.04..288.04 rows=8,150 width=8) (actual time=17.271..17.273 rows=8,158 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 383kB
7. 9.741 9.741 ↓ 1.0 8,158 1

Seq Scan on workplaces (cost=0.00..288.04 rows=8,150 width=8) (actual time=0.014..9.741 rows=8,158 loops=1)

  • Filter: ((status)::text = 'APPROVED'::text)
  • Rows Removed by Filter: 1,778
8. 0.030 7.540 ↑ 38.9 20 1

Hash (cost=211.64..211.64 rows=777 width=4) (actual time=7.539..7.540 rows=20 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
9. 0.054 7.510 ↑ 38.9 20 1

HashAggregate (cost=196.10..203.87 rows=777 width=4) (actual time=7.488..7.510 rows=20 loops=1)

  • Group Key: clinics.id
10. 0.720 7.456 ↑ 29.9 26 1

Hash Right Join (cost=182.65..194.15 rows=777 width=4) (actual time=6.422..7.456 rows=26 loops=1)

  • Hash Cond: (statisticians.clinic_id = clinics.id)
  • Filter: ((statisticians.user_id = 20) OR (hashed SubPlan 1))
  • Rows Removed by Filter: 1,713
11. 0.398 0.398 ↓ 1.1 382 1

Seq Scan on statisticians (cost=0.00..10.60 rows=345 width=8) (actual time=0.018..0.398 rows=382 loops=1)

  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 234
12. 1.453 3.166 ↓ 1.0 1,555 1

Hash (cost=71.51..71.51 rows=1,551 width=4) (actual time=3.165..3.166 rows=1,555 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 71kB
13. 1.713 1.713 ↓ 1.0 1,555 1

Seq Scan on clinics (cost=0.00..71.51 rows=1,551 width=4) (actual time=0.015..1.713 rows=1,555 loops=1)

14.          

SubPlan (for Hash Right Join)

15. 0.062 3.172 ↓ 3.8 19 1

Nested Loop (cost=12.29..91.74 rows=5 width=4) (actual time=0.432..3.172 rows=19 loops=1)

  • Join Filter: (statisticians_1.clinic_id = clinics_1.id)
16. 1.550 3.053 ↓ 3.8 19 1

Hash Join (cost=12.01..89.39 rows=5 width=12) (actual time=0.412..3.053 rows=19 loops=1)

  • Hash Cond: (child.parent_id = statisticians_1.clinic_id)
17. 1.417 1.417 ↓ 1.0 1,555 1

Seq Scan on clinics child (cost=0.00..71.51 rows=1,551 width=8) (actual time=0.006..1.417 rows=1,555 loops=1)

18. 0.009 0.086 ↑ 1.0 1 1

Hash (cost=12.00..12.00 rows=1 width=4) (actual time=0.085..0.086 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
19. 0.077 0.077 ↑ 1.0 1 1

Seq Scan on statisticians statisticians_1 (cost=0.00..12.00 rows=1 width=4) (actual time=0.021..0.077 rows=1 loops=1)

  • Filter: ((deleted_at IS NULL) AND (user_id = 20))
  • Rows Removed by Filter: 615
20. 0.057 0.057 ↑ 1.0 1 19

Index Only Scan using clinics_pkey on clinics clinics_1 (cost=0.28..0.46 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=19)

  • Index Cond: (id = child.parent_id)
  • Heap Fetches: 19
Planning time : 3.646 ms
Execution time : 7,429.435 ms