explain.depesz.com

PostgreSQL's explain analyze made readable

Result: QwNe

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=188,976.62..189,184.40 rows=10 width=719) (actual rows= loops=)

  • Hash Cond: ((t.province_id = l.province_id) AND (t.municipality_id = l.municipality_id) AND (t.town_id = l.town_id))
  • JIT:
  • Functions: 80
  • Options: Inlining false, Optimization false, Expressions true, Deforming true
2. 0.000 0.000 ↓ 0.0

Seq Scan on territory t (cost=0.00..132.88 rows=5,288 width=90) (actual rows= loops=)

3. 0.000 0.000 ↓ 0.0

Hash (cost=188,976.45..188,976.45 rows=10 width=640) (actual rows= loops=)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
4. 0.000 0.000 ↓ 0.0

Limit (cost=188,976.32..188,976.35 rows=10 width=640) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Sort (cost=188,976.32..189,587.62 rows=244,520 width=640) (actual rows= loops=)

  • Sort Key: p.id DESC, p.created_by DESC
6. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=94,662.71..183,692.33 rows=244,520 width=640) (actual rows= loops=)

  • Hash Cond: (p.occupation = oc.id)
7. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=94,661.42..179,377.08 rows=244,520 width=602) (actual rows= loops=)

  • Merge Cond: (p.id = c.person_id)
  • Filter: ((l.province_id = 1) OR (l.municipality_id = 1) OR (l.town_id = 1) OR (h.organization_id = 3) OR (p.created_by = 35) OR (p.organization_id = 3) OR p.is_driver)
8. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=1,239.29..82,867.15 rows=1,213,292 width=393) (actual rows= loops=)

  • Merge Cond: (p.id = mc.person_id)
9. 0.000 0.000 ↓ 0.0

Index Scan Backward using persons_pkey on persons p (cost=0.43..78,474.23 rows=1,213,292 width=369) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Sort (cost=1,238.86..1,259.00 rows=8,055 width=28) (actual rows= loops=)

  • Sort Key: mc.person_id DESC
11. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=19.32..716.26 rows=8,055 width=28) (actual rows= loops=)

  • Hash Cond: (mc.hospital_id = h.id)
12. 0.000 0.000 ↓ 0.0

Seq Scan on courses mc (cost=0.00..675.55 rows=8,055 width=24) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Hash (cost=14.70..14.70 rows=370 width=8) (actual rows= loops=)

  • Buckets: 1,024 Batches: 1 Memory Usage: 23kB
14. 0.000 0.000 ↓ 0.0

Seq Scan on hospitals h (cost=0.00..14.70 rows=370 width=8) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Sort (cost=93,422.13..93,426.68 rows=1,819 width=213) (actual rows= loops=)

  • Sort Key: c.person_id DESC
16. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=80,586.89..93,323.64 rows=1,819 width=213) (actual rows= loops=)

  • Hash Cond: (c.location_id = l.id)
17. 0.000 0.000 ↓ 0.0

Subquery Scan on c (cost=67,762.92..80,494.91 rows=1,819 width=172) (actual rows= loops=)

  • Filter: (c.rnk = 1)
18. 0.000 0.000 ↓ 0.0

WindowAgg (cost=67,762.92..75,947.77 rows=363,771 width=180) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Sort (cost=67,762.92..68,672.35 rows=363,771 width=172) (actual rows= loops=)

  • Sort Key: contacts.person_id, contacts.start_date DESC, contacts.location_id DESC
20. 0.000 0.000 ↓ 0.0

Seq Scan on contacts (cost=0.00..15,955.71 rows=363,771 width=172) (actual rows= loops=)

21. 0.000 0.000 ↓ 0.0

Hash (cost=8,989.54..8,989.54 rows=306,754 width=49) (actual rows= loops=)

  • Buckets: 524,288 Batches: 1 Memory Usage: 29,087kB
22. 0.000 0.000 ↓ 0.0

Seq Scan on locations l (cost=0.00..8,989.54 rows=306,754 width=49) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Hash (cost=1.13..1.13 rows=13 width=24) (actual rows= loops=)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
24. 0.000 0.000 ↓ 0.0

Seq Scan on occupations oc (cost=0.00..1.13 rows=13 width=24) (actual rows= loops=)

25.          

SubPlan (for Hash Right Join)

26. 0.000 0.000 ↓ 0.0

Index Only Scan using uploads_person_id_idx on uploads u (cost=0.42..2.66 rows=2 width=0) (actual rows= loops=)

  • Index Cond: (person_id = p.id)
27. 0.000 0.000 ↓ 0.0

Index Only Scan using uploads_person_id_idx on uploads u_1 (cost=0.42..10,140.14 rows=348,456 width=4) (actual rows= loops=)