explain.depesz.com

PostgreSQL's explain analyze made readable

Result: l29r

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 24,752.102 ↓ 0.0 0 1

Hash Right Join (cost=58,677.21..58,758.41 rows=1 width=141) (actual time=24,752.102..24,752.102 rows=0 loops=1)

  • Hash Cond: ((pr_1.mr_no)::text = (r.mr_no)::text)
2. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=29,311.91..29,346.03 rows=3,412 width=13) (never executed)

3. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..29,294.85 rows=3,412 width=13) (never executed)

4. 0.000 0.000 ↓ 0.0 0

Index Scan using bill_ip_deposit_set_off_idx on bill b_1 (cost=0.43..305.41 rows=3,664 width=16) (never executed)

  • Index Cond: (ip_deposit_set_off > 0::numeric)
5. 0.000 0.000 ↓ 0.0 0

Index Scan using patient_registration_pkey on patient_registration pr_1 (cost=0.43..7.90 rows=1 width=23) (never executed)

  • Index Cond: ((patient_id)::text = (b_1.visit_id)::text)
  • Filter: (visit_type <> 'i'::bpchar)
6. 0.001 24,752.098 ↓ 0.0 0 1

Hash (cost=29,365.29..29,365.29 rows=1 width=109) (actual time=24,752.098..24,752.098 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 0kB
7. 0.002 24,752.097 ↓ 0.0 0 1

Nested Loop Left Join (cost=29,357.07..29,365.29 rows=1 width=109) (actual time=24,752.097..24,752.097 rows=0 loops=1)

  • Join Filter: ((r.mr_no)::text = (pr_2.mr_no)::text)
8. 0.019 24,752.095 ↓ 0.0 0 1

Merge Join (cost=60.96..60.99 rows=1 width=77) (actual time=24,752.095..24,752.095 rows=0 loops=1)

  • Merge Cond: ((pr.mr_no)::text = (r.mr_no)::text)
9. 0.007 0.050 ↑ 1.0 1 1

Sort (cost=16.92..16.92 rows=1 width=13) (actual time=0.049..0.050 rows=1 loops=1)

  • Sort Key: pr.mr_no
  • Sort Method: quicksort Memory: 25kB
10. 0.004 0.043 ↑ 1.0 1 1

Nested Loop (cost=0.86..16.91 rows=1 width=13) (actual time=0.041..0.043 rows=1 loops=1)

11. 0.022 0.022 ↑ 1.0 1 1

Index Scan using bill_pkey on bill b (cost=0.43..8.45 rows=1 width=16) (actual time=0.022..0.022 rows=1 loops=1)

  • Index Cond: ((bill_no)::text = '19/20MIN0050497'::text)
12. 0.017 0.017 ↑ 1.0 1 1

Index Scan using patient_registration_pkey on patient_registration pr (cost=0.43..8.45 rows=1 width=23) (actual time=0.016..0.017 rows=1 loops=1)

  • Index Cond: ((patient_id)::text = (b.visit_id)::text)
13. 21.817 24,752.026 ↓ 29.0 29 1

Sort (cost=44.05..44.05 rows=1 width=74) (actual time=24,752.021..24,752.026 rows=29 loops=1)

  • Sort Key: r.mr_no
  • Sort Method: quicksort Memory: 519kB
14. 10.623 24,730.209 ↓ 4,199.0 4,199 1

HashAggregate (cost=14.66..44.03 rows=1 width=10) (actual time=60.231..24,730.209 rows=4,199 loops=1)

15. 4.776 54.660 ↓ 5,950.0 5,950 1

Nested Loop (cost=0.86..14.66 rows=1 width=10) (actual time=0.063..54.660 rows=5,950 loops=1)

16. 2.284 2.284 ↓ 5,950.0 5,950 1

Index Scan using idx_receipt_usage_entitytype_entityid on receipt_usage (cost=0.43..6.20 rows=1 width=10) (actual time=0.048..2.284 rows=5,950 loops=1)

  • Index Cond: (((entity_type)::text = 'visit_type'::text) AND ((entity_id)::text = 'i'::text))
17. 47.600 47.600 ↑ 1.0 1 5,950

Index Scan using receipts_pkey on receipts r (cost=0.43..8.45 rows=1 width=20) (actual time=0.008..0.008 rows=1 loops=5,950)

  • Index Cond: ((receipt_id)::text = (receipt_usage.receipt_id)::text)
  • Filter: is_deposit
18.          

SubPlan (for HashAggregate)

19. 8.398 24,593.543 ↑ 1.0 1 4,199

Aggregate (cost=14.67..14.68 rows=1 width=5) (actual time=5.856..5.857 rows=1 loops=4,199)

20. 10,230.627 24,585.145 ↑ 1.0 1 4,199

Nested Loop (cost=0.86..14.66 rows=1 width=5) (actual time=2.165..5.855 rows=1 loops=4,199)

  • Join Filter: ((r_1.receipt_id)::text = (receipt_usage_1.receipt_id)::text)
  • Rows Removed by Join Filter: 11577
21. 79.781 79.781 ↓ 2.0 2 4,199

Index Scan using idx_receipts_mrno_isdeposit on receipts r_1 (cost=0.43..8.45 rows=1 width=15) (actual time=0.018..0.019 rows=2 loops=4,199)

  • Index Cond: (((mr_no)::text = (r.mr_no)::text) AND (is_deposit = true))
  • Filter: (is_deposit AND ((realized)::bpchar = 'Y'::bpchar))
22. 14,274.737 14,274.737 ↓ 5,950.0 5,950 8,171

Index Scan using idx_receipt_usage_entitytype_entityid on receipt_usage receipt_usage_1 (cost=0.43..6.20 rows=1 width=10) (actual time=0.011..1.747 rows=5,950 loops=8,171)

  • Index Cond: (((entity_type)::text = 'visit_type'::text) AND ((entity_id)::text = 'i'::text))
23. 4.199 71.383 ↑ 1.0 1 4,199

Aggregate (cost=14.67..14.68 rows=1 width=5) (actual time=0.017..0.017 rows=1 loops=4,199)

24. 4.199 67.184 ↓ 0.0 0 4,199

Nested Loop (cost=0.86..14.66 rows=1 width=5) (actual time=0.016..0.016 rows=0 loops=4,199)

  • Join Filter: ((r_2.receipt_id)::text = (receipt_usage_2.receipt_id)::text)
25. 62.985 62.985 ↓ 0.0 0 4,199

Index Scan using idx_receipts_mrno_isdeposit on receipts r_2 (cost=0.43..8.45 rows=1 width=15) (actual time=0.015..0.015 rows=0 loops=4,199)

  • Index Cond: (((mr_no)::text = (r.mr_no)::text) AND (is_deposit = true))
  • Filter: (is_deposit AND ((realized)::bpchar <> 'Y'::bpchar))
  • Rows Removed by Filter: 2
26. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_receipt_usage_entitytype_entityid on receipt_usage receipt_usage_2 (cost=0.43..6.20 rows=1 width=10) (never executed)

  • Index Cond: (((entity_type)::text = 'visit_type'::text) AND ((entity_id)::text = 'i'::text))
27. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=29,296.11..29,298.63 rows=252 width=13) (never executed)

28. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..29,294.85 rows=252 width=13) (never executed)

29. 0.000 0.000 ↓ 0.0 0

Index Scan using bill_ip_deposit_set_off_idx on bill b_2 (cost=0.43..305.41 rows=3,664 width=16) (never executed)

  • Index Cond: (ip_deposit_set_off > 0::numeric)
30. 0.000 0.000 ↓ 0.0 0

Index Scan using patient_registration_pkey on patient_registration pr_2 (cost=0.43..7.90 rows=1 width=23) (never executed)

  • Index Cond: ((patient_id)::text = (b_2.visit_id)::text)
  • Filter: (visit_type = 'i'::bpchar)
Total runtime : 24,752.435 ms