explain.depesz.com

PostgreSQL's explain analyze made readable

Result: SPMs

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 3.021 ↑ 1.0 1 1

Limit (cost=35.30..35.31 rows=1 width=117) (actual time=3.015..3.021 rows=1 loops=1)

2. 0.017 3.014 ↑ 1.0 1 1

Sort (cost=35.30..35.31 rows=1 width=117) (actual time=3.010..3.014 rows=1 loops=1)

  • Sort Key: patient.patient_id DESC
  • Sort Method: quicksort Memory: 25kB
3. 0.010 2.997 ↑ 1.0 1 1

Nested Loop (cost=27.43..35.29 rows=1 width=117) (actual time=2.951..2.997 rows=1 loops=1)

4. 0.009 2.954 ↑ 1.0 1 1

Nested Loop Left Join (cost=27.43..29.69 rows=1 width=107) (actual time=2.936..2.954 rows=1 loops=1)

5. 0.013 2.930 ↑ 1.0 1 1

Nested Loop (cost=27.28..28.90 rows=1 width=102) (actual time=2.915..2.930 rows=1 loops=1)

6. 0.095 2.887 ↓ 2.0 2 1

Hash Join (cost=27.14..28.33 rows=1 width=108) (actual time=2.796..2.887 rows=2 loops=1)

  • Hash Cond: ((p.patient_id)::text = (inspection_rank.patient_id)::text)
7. 0.253 2.641 ↓ 1.1 44 1

HashAggregate (cost=26.01..26.62 rows=41 width=42) (actual time=2.530..2.641 rows=44 loops=1)

  • Group Key: p.patient_id
8. 0.184 2.388 ↓ 1.2 49 1

Hash Right Join (cost=24.70..25.29 rows=41 width=27) (actual time=2.130..2.388 rows=49 loops=1)

  • Hash Cond: ((uxp.patient_id)::text = (p.patient_id)::text)
9. 0.192 2.025 ↓ 1.2 44 1

Sort (cost=21.78..21.87 rows=38 width=59) (actual time=1.940..2.025 rows=44 loops=1)

  • Sort Key: ((((u.last_name)::text || ' '::text) || (u.first_name)::text)) DESC
  • Sort Method: quicksort Memory: 28kB
10. 0.183 1.833 ↓ 1.2 44 1

Hash Left Join (cost=19.11..20.78 rows=38 width=59) (actual time=1.587..1.833 rows=44 loops=1)

  • Hash Cond: ((uxp.user_id)::text = (u.user_id)::text)
11. 0.089 0.089 ↓ 1.2 44 1

Seq Scan on user_x_patients uxp (cost=0.00..1.38 rows=38 width=14) (actual time=0.008..0.089 rows=44 loops=1)

  • Filter: (NOT is_deleted)
12. 0.784 1.561 ↑ 1.0 405 1

Hash (cost=14.05..14.05 rows=405 width=21) (actual time=1.559..1.561 rows=405 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 30kB
13. 0.777 0.777 ↑ 1.0 405 1

Seq Scan on users u (cost=0.00..14.05 rows=405 width=21) (actual time=0.007..0.777 rows=405 loops=1)

14. 0.091 0.179 ↓ 1.1 44 1

Hash (cost=2.41..2.41 rows=41 width=10) (actual time=0.177..0.179 rows=44 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
15. 0.088 0.088 ↓ 1.1 44 1

Seq Scan on patients p (cost=0.00..2.41 rows=41 width=10) (actual time=0.007..0.088 rows=44 loops=1)

16. 0.014 0.151 ↓ 2.0 2 1

Hash (cost=1.12..1.12 rows=1 width=66) (actual time=0.150..0.151 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
17. 0.019 0.137 ↓ 2.0 2 1

Subquery Scan on inspection_rank (cost=1.05..1.12 rows=1 width=66) (actual time=0.079..0.137 rows=2 loops=1)

  • Filter: ((inspection_rank.rank = 1) AND (inspection_rank.status = 0))
  • Rows Removed by Filter: 4
18. 0.052 0.118 ↓ 3.0 6 1

WindowAgg (cost=1.05..1.09 rows=2 width=82) (actual time=0.074..0.118 rows=6 loops=1)

19. 0.040 0.066 ↓ 3.0 6 1

Sort (cost=1.05..1.05 rows=2 width=74) (actual time=0.054..0.066 rows=6 loops=1)

  • Sort Key: inspections.patient_id, inspections.end_date DESC, inspections.created_at DESC
  • Sort Method: quicksort Memory: 25kB
20. 0.026 0.026 ↓ 3.0 6 1

Seq Scan on inspections (cost=0.00..1.04 rows=2 width=74) (actual time=0.012..0.026 rows=6 loops=1)

  • Filter: (NOT is_deleted)
21. 0.030 0.030 ↓ 0.0 0 2

Index Scan using patients_pkey on patients patient (cost=0.14..0.55 rows=1 width=52) (actual time=0.014..0.015 rows=0 loops=2)

  • Index Cond: ((patient_id)::text = (p.patient_id)::text)
  • Filter: ((NOT is_deleted) AND (created_at <= now()))
  • Rows Removed by Filter: 0
22. 0.015 0.015 ↑ 1.0 1 1

Index Scan using organizations_pkey on organizations organization (cost=0.14..0.78 rows=1 width=19) (actual time=0.014..0.015 rows=1 loops=1)

  • Index Cond: ((patient.organization_id)::text = (organization_id)::text)
23. 0.033 0.033 ↑ 1.0 1 1

Seq Scan on code_masters (cost=0.00..5.59 rows=1 width=12) (actual time=0.008..0.033 rows=1 loops=1)

  • Filter: ((code_value = 0) AND ((code_id)::text = 'D-C-3-1'::text))
  • Rows Removed by Filter: 172