explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1xCS : Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: 1; plan #DTLq; plan #j7pc; plan #N5av; plan #R6O; plan #pAxf; plan #27bx; plan #VEa0; plan #Nh3s; plan #IN2b; plan #XXES

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 994.271 225,827.115 ↓ 4,470.0 4,470 1

Merge Join (cost=1,111.35..22,031.08 rows=1 width=1,823) (actual time=203.234..225,827.115 rows=4,470 loops=1)

  • Merge Cond: (((b.fc_mo)::text = (t1.org_code_oms)::text) AND ((b.fc_opl)::text = (t1.payment_method_code)::text))
  • Join Filter: (((b.det)::text = t1.det) AND ((b.usl_ok)::text = t1.care_regimen_code) AND (daterange(b.date_b, b.date_e, '[]'::text) @> t1.case_close_date) AND CASE t1.init_goal_id WHEN 19 THEN ((b.c_serv)::text = '1021'::text) ELSE ((b.c_serv)::text = (t1.service_code)::text) END)
  • Rows Removed by Join Filter: 740816
2.          

CTE t1

3. 4.971 45.239 ↓ 4.5 4,470 1

Hash Join (cost=919.66..1,041.02 rows=1,001 width=128) (actual time=34.959..45.239 rows=4,470 loops=1)

  • Hash Cond: (g.init_goal_id = i.id)
4. 1.475 40.256 ↓ 4.5 4,470 1

Hash Left Join (cost=918.21..982.02 rows=1,001 width=124) (actual time=34.933..40.256 rows=4,470 loops=1)

  • Hash Cond: (g.care_regimen_id = c.id)
5. 1.777 38.773 ↓ 4.5 4,470 1

Hash Left Join (cost=917.03..967.07 rows=1,001 width=124) (actual time=34.919..38.773 rows=4,470 loops=1)

  • Hash Cond: (g.payment_method_id = p.id)
6. 1.663 36.971 ↓ 4.5 4,470 1

Merge Right Join (cost=914.06..950.34 rows=1,001 width=126) (actual time=34.880..36.971 rows=4,470 loops=1)

  • Merge Cond: (o.org_id = g.org_id)
7. 0.026 0.026 ↑ 131.3 3 1

Index Scan using fk_pim_org_code_to_org on pim_org_code o (cost=0.42..12,256.31 rows=394 width=16) (actual time=0.010..0.026 rows=3 loops=1)

  • Filter: (type_id = 7)
  • Rows Removed by Filter: 10
8. 2.664 35.282 ↓ 4.5 4,470 1

Sort (cost=913.64..916.14 rows=1,001 width=114) (actual time=34.859..35.282 rows=4,470 loops=1)

  • Sort Key: g.org_id
  • Sort Method: quicksort Memory: 1380kB
9. 32.618 32.618 ↓ 4.5 4,470 1

Index Scan using fin_bill_generate_bill_id_idx on fin_bill_generate g (cost=0.43..863.76 rows=1,001 width=114) (actual time=0.021..32.618 rows=4,470 loops=1)

  • Index Cond: (bill_id = 842)
  • Filter: ((NOT is_sifted) AND ((region_data ->> 'is_tariff_service'::text))::boolean)
  • Rows Removed by Filter: 29552
10. 0.010 0.025 ↑ 1.0 43 1

Hash (cost=2.43..2.43 rows=43 width=6) (actual time=0.025..0.025 rows=43 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
11. 0.015 0.015 ↑ 1.0 43 1

Seq Scan on mc_payment_method p (cost=0.00..2.43 rows=43 width=6) (actual time=0.004..0.015 rows=43 loops=1)

12. 0.003 0.008 ↑ 1.0 8 1

Hash (cost=1.08..1.08 rows=8 width=8) (actual time=0.008..0.008 rows=8 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
13. 0.005 0.005 ↑ 1.0 8 1

Seq Scan on mc_care_regimen c (cost=0.00..1.08 rows=8 width=8) (actual time=0.004..0.005 rows=8 loops=1)

14. 0.007 0.012 ↑ 1.0 20 1

Hash (cost=1.20..1.20 rows=20 width=8) (actual time=0.012..0.012 rows=20 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
15. 0.005 0.005 ↑ 1.0 20 1

Seq Scan on mc_case_init_goal i (cost=0.00..1.20 rows=20 width=8) (actual time=0.002..0.005 rows=20 loops=1)

16. 50.055 50.055 ↑ 1.6 94,742 1

Index Scan using billing_tariff_services_fc_mo_fc_opl_idx on billing_tariff_services b (cost=0.42..17,405.65 rows=147,665 width=49) (actual time=0.015..50.055 rows=94,742 loops=1)

17. 60.655 110.833 ↓ 744.4 745,162 1

Sort (cost=69.91..72.41 rows=1,001 width=1,867) (actual time=53.230..110.833 rows=745,162 loops=1)

  • Sort Key: t1.org_code_oms, t1.payment_method_code
  • Sort Method: quicksort Memory: 821kB
18. 50.178 50.178 ↓ 4.5 4,470 1

CTE Scan on t1 (cost=0.00..20.02 rows=1,001 width=1,867) (actual time=34.965..50.178 rows=4,470 loops=1)

19.          

SubPlan (forMerge Join)

20. 224,671.956 224,671.956 ↓ 3.6 725 3,988

Seq Scan on billing_tariff_services (cost=0.00..5,293.14 rows=200 width=4) (actual time=26.408..56.337 rows=725 loops=3,988)

  • Filter: ((t1.case_open_date >= COALESCE(date_b, '-infinity'::date)) AND (t1.case_open_date <= COALESCE(date_e, '-infinity'::date)) AND ((fc_opl)::text = '28'::text))
  • Rows Removed by Filter: 146940
Planning time : 1.103 ms
Execution time : 225,829.468 ms