explain.depesz.com

PostgreSQL's explain analyze made readable

Result: VJfQ : Optimization for: plan #7fni

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 166.285 1,740.346 ↓ 1,805.0 1,805 1

Merge Join (cost=306,604.11..308,591.07 rows=1 width=1,818) (actual time=1,582.600..1,740.346 rows=1,805 loops=1)

  • Merge Cond: (((t1.org_code_oms)::text = (b.fc_mo)::text) AND ((t1.payment_method_code)::text = (b.fc_opl)::text) AND (t1.det = (b.det)::text) AND (t1.care_regimen_code = (b.usl_ok)::text))
  • Join Filter: ((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: 147107
2.          

CTE t1

3. 3.316 126.469 ↑ 6.3 1,805 1

Nested Loop (cost=16.57..279,633.53 rows=11,305 width=158) (actual time=0.517..126.469 rows=1,805 loops=1)

4. 0.249 121.348 ↑ 6.3 1,805 1

Nested Loop (cost=16.43..277,487.71 rows=11,305 width=154) (actual time=0.506..121.348 rows=1,805 loops=1)

5. 1.568 117.489 ↑ 6.3 1,805 1

Nested Loop (cost=16.43..264,769.58 rows=11,305 width=126) (actual time=0.498..117.489 rows=1,805 loops=1)

6. 0.272 108.701 ↑ 6.3 1,805 1

Nested Loop (cost=16.43..235,857.04 rows=11,305 width=128) (actual time=0.481..108.701 rows=1,805 loops=1)

7. 5.544 5.544 ↑ 6.3 1,805 1

Index Scan using fin_bill_generate_bill_id_idx on fin_bill_generate g (cost=0.43..9,412.24 rows=11,305 width=116) (actual time=0.228..5.544 rows=1,805 loops=1)

  • Index Cond: (bill_id = 791)
  • Filter: ((NOT is_sifted) AND ((region_data ->> 'is_tariff_service'::text))::boolean)
  • Rows Removed by Filter: 2344
8. 1.805 102.885 ↑ 1.0 1 1,805

Limit (cost=16.00..20.01 rows=1 width=12) (actual time=0.057..0.057 rows=1 loops=1,805)

9. 3.610 101.080 ↑ 1.0 1 1,805

Bitmap Heap Scan on pim_org_code (cost=16.00..20.01 rows=1 width=12) (actual time=0.056..0.056 rows=1 loops=1,805)

  • Recheck Cond: ((org_id = g.org_id) AND (type_id = 7))
  • Heap Blocks: exact=1805
10. 1.805 97.470 ↓ 0.0 0 1,805

BitmapAnd (cost=16.00..16.00 rows=1 width=0) (actual time=0.054..0.054 rows=0 loops=1,805)

11. 5.415 5.415 ↓ 1.2 7 1,805

Bitmap Index Scan on fk_pim_org_code_to_org (cost=0.00..4.46 rows=6 width=0) (actual time=0.003..0.003 rows=7 loops=1,805)

  • Index Cond: (org_id = g.org_id)
12. 90.250 90.250 ↓ 1.8 688 1,805

Bitmap Index Scan on fkc6856cb3ec5d17fa (cost=0.00..11.28 rows=382 width=0) (actual time=0.050..0.050 rows=688 loops=1,805)

  • Index Cond: (type_id = 7)
13. 0.000 7.220 ↑ 1.0 1 1,805

Limit (cost=0.00..2.54 rows=1 width=2) (actual time=0.004..0.004 rows=1 loops=1,805)

14. 7.220 7.220 ↑ 1.0 1 1,805

Seq Scan on mc_payment_method (cost=0.00..2.54 rows=1 width=2) (actual time=0.004..0.004 rows=1 loops=1,805)

  • Filter: (id = g.payment_method_id)
  • Rows Removed by Filter: 29
15. 1.805 3.610 ↑ 1.0 1 1,805

Limit (cost=0.00..1.10 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=1,805)

16. 1.805 1.805 ↑ 1.0 1 1,805

Seq Scan on mc_care_regimen (cost=0.00..1.10 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=1,805)

  • Filter: (id = g.care_regimen_id)
17. 1.805 1.805 ↑ 1.0 1 1,805

Index Scan using mc_case_init_goal_pk on mc_case_init_goal i (cost=0.14..0.16 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=1,805)

  • Index Cond: (id = g.init_goal_id)
18. 1.892 130.354 ↑ 6.3 1,805 1

Sort (cost=10,108.19..10,136.45 rows=11,305 width=1,863) (actual time=130.121..130.354 rows=1,805 loops=1)

  • Sort Key: t1.org_code_oms, t1.payment_method_code, t1.det, t1.care_regimen_code
  • Sort Method: quicksort Memory: 196kB
19. 128.462 128.462 ↑ 6.3 1,805 1

CTE Scan on t1 (cost=0.00..226.10 rows=11,305 width=1,863) (actual time=0.522..128.462 rows=1,805 loops=1)

20. 1,410.164 1,443.707 ↓ 1.6 243,175 1

Sort (cost=16,862.39..17,231.51 rows=147,648 width=48) (actual time=1,386.464..1,443.707 rows=243,175 loops=1)

  • Sort Key: b.fc_mo, b.fc_opl, b.det, b.usl_ok
  • Sort Method: external sort Disk: 10136kB
21. 33.543 33.543 ↓ 1.0 147,665 1

Seq Scan on billing_tariff_services b (cost=0.00..4,185.48 rows=147,648 width=48) (actual time=0.004..33.543 rows=147,665 loops=1)

Planning time : 3.053 ms
Execution time : 1,742.964 ms