explain.depesz.com

PostgreSQL's explain analyze made readable

Result: w6WI : Optimization for: Optimization for: plan #Jh5p; plan #sX88

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.026 366.512 ↓ 2.0 2 1

Group (cost=31,889.81..31,889.82 rows=1 width=17) (actual time=366.475..366.512 rows=2 loops=1)

  • Group Key: aps.id, (true)
2.          

CTE aps

3. 0.005 0.026 ↓ 2.0 2 1

Nested Loop (cost=0.56..16.61 rows=1 width=16) (actual time=0.017..0.026 rows=2 loops=1)

4. 0.011 0.011 ↓ 2.0 2 1

Index Scan using attendances_patient_id_idx on attendances a (cost=0.28..8.30 rows=1 width=16) (actual time=0.009..0.011 rows=2 loops=1)

  • Index Cond: (patient_id = '54d9df16-5371-11e8-80ea-034fb4ed6904'::uuid)
5. 0.010 0.010 ↑ 1.0 1 2

Index Scan using attendance_periods_attendance_id_idx on attendance_periods ap (cost=0.28..8.30 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=2)

  • Index Cond: (attendance_id = a.id)
6. 0.074 366.486 ↓ 231.0 231 1

Sort (cost=31,873.20..31,873.20 rows=1 width=17) (actual time=366.473..366.486 rows=231 loops=1)

  • Sort Key: aps.id, (true)
  • Sort Method: quicksort Memory: 43kB
7. 0.054 366.412 ↓ 231.0 231 1

Nested Loop Left Join (cost=1,008.34..31,873.19 rows=1 width=17) (actual time=113.570..366.412 rows=231 loops=1)

  • Join Filter: (apa.attendance_period_id = aps.id)
  • Rows Removed by Join Filter: 231
8. 0.022 0.022 ↓ 2.0 2 1

CTE Scan on aps (cost=0.00..0.02 rows=1 width=16) (actual time=0.020..0.022 rows=2 loops=1)

9. 65.874 366.336 ↓ 231.0 231 2

Hash Semi Join (cost=1,008.34..31,873.16 rows=1 width=17) (actual time=40.572..183.168 rows=231 loops=2)

  • Hash Cond: (apa.attendance_period_id = aps_1.id)
10. 24.636 300.450 ↓ 76.7 256,097 2

Gather (cost=1,008.30..31,864.34 rows=3,341 width=16) (actual time=1.980..150.225 rows=256,097 loops=2)

  • Workers Planned: 2
  • Workers Launched: 2
11. 144.089 275.814 ↓ 61.3 85,366 6 / 3

Hash Join (cost=8.30..30,530.24 rows=1,392 width=16) (actual time=0.110..137.907 rows=85,366 loops=6)

  • Hash Cond: (apa.user_group_id = users_user_groups.user_group_id)
12. 131.692 131.692 ↑ 1.4 473,833 6 / 3

Parallel Seq Scan on attendance_period_acl apa (cost=0.00..28,712.00 rows=683,600 width=32) (actual time=0.023..65.846 rows=473,833 loops=6)

13. 0.005 0.033 ↑ 1.0 1 5 / 3

Hash (cost=8.29..8.29 rows=1 width=16) (actual time=0.020..0.020 rows=1 loops=5)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
14. 0.028 0.028 ↑ 1.0 1 5 / 3

Index Scan using users_user_groups_user_id_idx on users_user_groups (cost=0.27..8.29 rows=1 width=16) (actual time=0.016..0.017 rows=1 loops=5)

  • Index Cond: (user_id = '1304ff22-3368-11e8-ba9d-43a62f2ef9fd'::uuid)
15. 0.002 0.012 ↓ 2.0 2 1

Hash (cost=0.02..0.02 rows=1 width=16) (actual time=0.012..0.012 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
16. 0.010 0.010 ↓ 2.0 2 1

CTE Scan on aps aps_1 (cost=0.00..0.02 rows=1 width=16) (actual time=0.000..0.010 rows=2 loops=1)

Planning time : 0.871 ms
Execution time : 368.088 ms