explain.depesz.com

PostgreSQL's explain analyze made readable

Result: PBev

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

Limit (cost=35.30..35.31 rows=1 width=117) (actual time=3.006..3.013 rows=1 loops=1)

2. 0.014 3.006 ↑ 1.0 1 1

Sort (cost=35.30..35.31 rows=1 width=117) (actual time=3.002..3.006 rows=1 loops=1)

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

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

4. 0.008 2.947 ↑ 1.0 1 1

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

5. 0.014 2.924 ↑ 1.0 1 1

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

6. 0.094 2.888 ↓ 2.0 2 1

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

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

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

  • Group Key: p.patient_id
8. 0.198 2.394 ↓ 1.2 49 1

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

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

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

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

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

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

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

  • Filter: (NOT is_deleted)
12. 0.806 1.574 ↑ 1.0 405 1

Hash (cost=14.05..14.05 rows=405 width=21) (actual time=1.572..1.574 rows=405 loops=1)

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

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

14. 0.088 0.177 ↓ 1.1 44 1

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

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

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

16. 0.011 0.148 ↓ 2.0 2 1

Hash (cost=1.12..1.12 rows=1 width=66) (actual time=0.147..0.148 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.081..0.137 rows=2 loops=1)

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

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

19. 0.044 0.071 ↓ 3.0 6 1

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

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

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

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

Index Scan using patients_pkey on patients patient (cost=0.14..0.55 rows=1 width=52) (actual time=0.010..0.011 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.013..0.015 rows=1 loops=1)

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

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

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