explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Qkea

Settings
# exclusive inclusive rows x rows loops node
1. 0.010 3.391 ↑ 1.0 50 1

Limit (cost=123.58..126.77 rows=50 width=133) (actual time=3.356..3.391 rows=50 loops=1)

2. 0.037 3.381 ↑ 2.6 50 1

Nested Loop Left Join (cost=123.58..131.76 rows=128 width=133) (actual time=3.355..3.381 rows=50 loops=1)

  • Join Filter: (inspection_rank.status = code_masters.code_value)
  • Rows Removed by Join Filter: 50
3. 0.012 3.344 ↑ 2.6 50 1

Merge Left Join (cost=123.58..124.24 rows=128 width=125) (actual time=3.333..3.344 rows=50 loops=1)

  • Merge Cond: ((patient.patient_id)::text = (inspection_rank.patient_id)::text)
4. 0.295 2.796 ↑ 2.6 50 1

Sort (cost=104.01..104.33 rows=128 width=107) (actual time=2.793..2.796 rows=50 loops=1)

  • Sort Key: patient.patient_id DESC
  • Sort Method: quicksort Memory: 45kB
5. 0.770 2.501 ↑ 1.5 83 1

Hash Left Join (cost=90.51..99.53 rows=128 width=107) (actual time=2.429..2.501 rows=83 loops=1)

  • Hash Cond: ((patient.organization_id)::text = (organization.organization_id)::text)
6. 0.034 1.588 ↑ 1.5 83 1

Hash Join (cost=71.57..80.26 rows=128 width=102) (actual time=1.533..1.588 rows=83 loops=1)

  • Hash Cond: ((patient.patient_id)::text = (patient_with_users.patient_id)::text)
7. 0.046 0.046 ↑ 1.5 83 1

Seq Scan on patients patient (cost=0.00..8.34 rows=128 width=70) (actual time=0.012..0.046 rows=83 loops=1)

  • Filter: ((NOT is_deleted) AND (created_at <= now()))
  • Rows Removed by Filter: 17
8. 0.018 1.508 ↑ 1.6 100 1

Hash (cost=69.62..69.62 rows=156 width=42) (actual time=1.508..1.508 rows=100 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 18kB
9. 0.010 1.490 ↑ 1.6 100 1

Subquery Scan on patient_with_users (cost=65.72..69.62 rows=156 width=42) (actual time=1.422..1.490 rows=100 loops=1)

10. 0.910 1.480 ↑ 1.6 100 1

HashAggregate (cost=65.72..68.06 rows=156 width=42) (actual time=1.421..1.480 rows=100 loops=1)

  • Group Key: p.patient_id
11. 0.065 0.570 ↓ 1.1 191 1

Hash Right Join (cost=58.42..62.80 rows=167 width=34) (actual time=0.496..0.570 rows=191 loops=1)

  • Hash Cond: ((uxp.patient_id)::text = (p.patient_id)::text)
12. 0.144 0.473 ↓ 1.1 191 1

Sort (cost=48.91..49.32 rows=167 width=66) (actual time=0.460..0.473 rows=191 loops=1)

  • Sort Key: ((((u.last_name)::text || ' '::text) || (u.first_name)::text)) DESC
  • Sort Method: quicksort Memory: 46kB
13. 0.057 0.329 ↓ 1.1 191 1

Hash Left Join (cost=37.80..42.74 rows=167 width=66) (actual time=0.254..0.329 rows=191 loops=1)

  • Hash Cond: ((uxp.user_id)::text = (u.user_id)::text)
14. 0.029 0.029 ↓ 1.1 191 1

Seq Scan on user_x_patients uxp (cost=0.00..3.67 rows=167 width=18) (actual time=0.005..0.029 rows=191 loops=1)

  • Filter: (NOT is_deleted)
15. 0.116 0.243 ↓ 1.0 803 1

Hash (cost=27.91..27.91 rows=791 width=24) (actual time=0.243..0.243 rows=803 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 53kB
16. 0.127 0.127 ↓ 1.0 803 1

Seq Scan on users u (cost=0.00..27.91 rows=791 width=24) (actual time=0.004..0.127 rows=803 loops=1)

17. 0.013 0.032 ↑ 1.6 100 1

Hash (cost=7.56..7.56 rows=156 width=10) (actual time=0.032..0.032 rows=100 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 13kB
18. 0.019 0.019 ↑ 1.6 100 1

Seq Scan on patients p (cost=0.00..7.56 rows=156 width=10) (actual time=0.002..0.019 rows=100 loops=1)

19. 0.071 0.143 ↓ 1.0 399 1

Hash (cost=13.97..13.97 rows=397 width=20) (actual time=0.143..0.143 rows=399 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 29kB
20. 0.072 0.072 ↓ 1.0 399 1

Seq Scan on organizations organization (cost=0.00..13.97 rows=397 width=20) (actual time=0.011..0.072 rows=399 loops=1)

21. 0.506 0.536 ↑ 1.0 1 1

Sort (cost=19.57..19.58 rows=1 width=66) (actual time=0.536..0.536 rows=1 loops=1)

  • Sort Key: inspection_rank.patient_id DESC
  • Sort Method: quicksort Memory: 25kB
22. 0.002 0.030 ↑ 1.0 1 1

Subquery Scan on inspection_rank (cost=15.62..19.56 rows=1 width=66) (actual time=0.024..0.030 rows=1 loops=1)

  • Filter: ((inspection_rank.rank = 1) AND (inspection_rank.status = 1))
  • Rows Removed by Filter: 4
23. 0.012 0.028 ↑ 21.0 5 1

WindowAgg (cost=15.62..17.99 rows=105 width=82) (actual time=0.022..0.028 rows=5 loops=1)

24. 0.008 0.016 ↑ 21.0 5 1

Sort (cost=15.62..15.89 rows=105 width=74) (actual time=0.015..0.016 rows=5 loops=1)

  • Sort Key: inspections.patient_id, inspections.end_date DESC, inspections.created_at DESC
  • Sort Method: quicksort Memory: 25kB
25. 0.008 0.008 ↑ 21.0 5 1

Seq Scan on inspections (cost=0.00..12.10 rows=105 width=74) (actual time=0.007..0.008 rows=5 loops=1)

  • Filter: (NOT is_deleted)
26. 0.000 0.000 ↑ 1.0 1 50

Materialize (cost=0.00..5.60 rows=1 width=12) (actual time=0.000..0.000 rows=1 loops=50)

27. 0.018 0.018 ↑ 1.0 1 1

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

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