explain.depesz.com

PostgreSQL's explain analyze made readable

Result: JeCx : Optimization for: Optimization for: 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; plan #1xCS; plan #905

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 850.285 228,014.336 ↓ 4,470.0 4,470 1

Merge Join (cost=1,111.35..22,031.08 rows=1 width=1,823) (actual time=207.413..228,014.336 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: ((t1.case_close_date >= b.date_b) AND (t1.case_close_date <= b.date_e) AND (t1.det = (b.det)::text) AND (t1.care_regimen_code = (b.usl_ok)::text) 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. 5.067 45.747 ↓ 4.5 4,470 1

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

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

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

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

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

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

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

  • Merge Cond: (o.org_id = g.org_id)
7. 0.027 0.027 ↑ 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.011..0.027 rows=3 loops=1)

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

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

  • Sort Key: g.org_id
  • Sort Method: quicksort Memory: 1380kB
9. 33.074 33.074 ↓ 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.035..33.074 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.012 0.031 ↑ 1.0 43 1

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

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

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

12. 0.002 0.009 ↑ 1.0 8 1

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

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

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

14. 0.007 0.013 ↑ 1.0 20 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
15. 0.006 0.006 ↑ 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.006 rows=20 loops=1)

16. 50.857 50.857 ↑ 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.857 rows=94,742 loops=1)

17. 61.403 112.246 ↓ 744.4 745,162 1

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

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

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

19.          

SubPlan (for Merge Join)

20. 227,000.948 227,000.948 ↓ 3.6 725 3,988

Seq Scan on billing_tariff_services (cost=0.00..5,293.14 rows=200 width=4) (actual time=26.675..56.921 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.124 ms
Execution time : 228,016.437 ms