explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5Mo2

Settings
# exclusive inclusive rows x rows loops node
1. 35.458 268.621 ↓ 10,542.0 10,542 1

Nested Loop (cost=773.19..917.17 rows=1 width=118) (actual time=51.850..268.621 rows=10,542 loops=1)

2. 39.131 194.453 ↓ 19,355.0 19,355 1

Nested Loop (cost=773.14..917.08 rows=1 width=72) (actual time=51.839..194.453 rows=19,355 loops=1)

3. 29.475 97.257 ↓ 19,355.0 19,355 1

Hash Join (cost=773.08..916.99 rows=1 width=31) (actual time=51.818..97.257 rows=19,355 loops=1)

  • Hash Cond: ((patient_details.patient_id = pd.patient_id) AND ((max(patient_details.created_at)) = pd.created_at))
4. 33.284 42.919 ↓ 1.0 19,355 1

HashAggregate (cost=357.76..415.32 rows=19,188 width=12) (actual time=26.843..42.919 rows=19,355 loops=1)

  • Group Key: patient_details.patient_id
5. 9.635 9.635 ↓ 1.0 19,356 1

Seq Scan on patient_details (cost=0.00..338.57 rows=19,189 width=12) (actual time=0.012..9.635 rows=19,356 loops=1)

6. 13.553 24.863 ↓ 1.0 19,356 1

Hash (cost=338.57..338.57 rows=19,189 width=35) (actual time=24.863..24.863 rows=19,356 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 1607kB
7. 11.310 11.310 ↓ 1.0 19,356 1

Seq Scan on patient_details pd (cost=0.00..338.57 rows=19,189 width=35) (actual time=0.032..11.310 rows=19,356 loops=1)

8. 58.065 58.065 ↑ 1.0 1 19,355

Index Scan using patients_pkey on patients p (cost=0.06..0.09 rows=1 width=41) (actual time=0.003..0.003 rows=1 loops=19,355)

  • Index Cond: (id = pd.patient_id)
9. 38.710 38.710 ↑ 1.0 1 19,355

Index Scan using index_cases_on_patient_id on cases c (cost=0.06..0.08 rows=1 width=50) (actual time=0.002..0.002 rows=1 loops=19,355)

  • Index Cond: (patient_id = p.id)
Planning time : 0.927 ms
Execution time : 273.329 ms