explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZuEW

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 537.668 ↓ 0.0 0 1

Hash Right Join (cost=113,237.44..113,318.65 rows=1 width=141) (actual time=537.668..537.668 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.000 537.663 ↓ 0.0 0 1

Hash (cost=83,925.52..83,925.52 rows=1 width=109) (actual time=537.663..537.663 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 0kB
7. 0.002 537.663 ↓ 0.0 0 1

Nested Loop Left Join (cost=83,917.31..83,925.52 rows=1 width=109) (actual time=537.663..537.663 rows=0 loops=1)

  • Join Filter: ((r.mr_no)::text = (pr_2.mr_no)::text)
8. 0.016 537.661 ↓ 0.0 0 1

Merge Join (cost=54,621.20..54,621.22 rows=1 width=77) (actual time=537.661..537.661 rows=0 loops=1)

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

Sort (cost=16.92..16.92 rows=1 width=13) (actual time=0.047..0.048 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.021 0.021 ↑ 1.0 1 1

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

  • Index Cond: ((bill_no)::text = '19/20MIN0050497'::text)
12. 0.018 0.018 ↑ 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.017..0.018 rows=1 loops=1)

  • Index Cond: ((patient_id)::text = (b.visit_id)::text)
13. 20.916 537.597 ↓ 29.0 29 1

Sort (cost=54,604.28..54,604.29 rows=1 width=74) (actual time=537.591..537.597 rows=29 loops=1)

  • Sort Key: r.mr_no
  • Sort Method: quicksort Memory: 519kB
14. 11.106 516.681 ↓ 4,199.0 4,199 1

HashAggregate (cost=54,570.73..54,604.26 rows=1 width=10) (actual time=306.525..516.681 rows=4,199 loops=1)

15. 4.426 304.023 ↓ 5,950.0 5,950 1

Nested Loop (cost=0.43..54,570.72 rows=1 width=10) (actual time=249.440..304.023 rows=5,950 loops=1)

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

Seq Scan on receipt_usage (cost=0.00..54,562.26 rows=1 width=10) (actual time=249.413..251.997 rows=5,950 loops=1)

  • Filter: (((entity_type)::text = 'visit_type'::text) AND ((entity_id)::text = 'i'::text))
  • Rows Removed by Filter: 2385001
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. 4.199 142.766 ↑ 1.0 1 4,199

Aggregate (cost=16.75..16.76 rows=1 width=5) (actual time=0.034..0.034 rows=1 loops=4,199)

20. 6.015 138.567 ↑ 1.0 1 4,199

Nested Loop (cost=0.86..16.75 rows=1 width=5) (actual time=0.026..0.033 rows=1 loops=4,199)

21. 67.184 67.184 ↓ 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.014..0.016 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. 65.368 65.368 ↑ 1.0 1 8,171

Index Scan using idx_receipt_usage_entitytype_entityid on receipt_usage receipt_usage_1 (cost=0.43..8.29 rows=1 width=10) (actual time=0.008..0.008 rows=1 loops=8,171)

  • Index Cond: (((receipt_id)::text = (r_1.receipt_id)::text) AND ((entity_type)::text = 'visit_type'::text))
  • Filter: ((entity_id)::text = 'i'::text)
23. 0.000 58.786 ↑ 1.0 1 4,199

Aggregate (cost=16.75..16.76 rows=1 width=5) (actual time=0.014..0.014 rows=1 loops=4,199)

24. 4.199 58.786 ↓ 0.0 0 4,199

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

25. 54.587 54.587 ↓ 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.013..0.013 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..8.29 rows=1 width=10) (never executed)

  • Index Cond: (((receipt_id)::text = (r_2.receipt_id)::text) AND ((entity_type)::text = 'visit_type'::text))
  • Filter: ((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 : 537.994 ms