explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2qqi

Settings
# exclusive inclusive rows x rows loops node
1. 0.087 12,547.241 ↑ 1.0 250 1

Limit (cost=206,164.78..206,165.40 rows=250 width=89) (actual time=12,547.109..12,547.241 rows=250 loops=1)

2.          

CTE hierar

3. 0.119 0.119 ↓ 3.0 3 1

Seq Scan on d_hierarchy_2018_12_19_11_40_44 (cost=0.00..19.04 rows=1 width=7) (actual time=0.016..0.119 rows=3 loops=1)

  • Filter: (((level_03_cd)::text = '153'::text) AND ((sales_segment_cd)::text = ANY ('{100,101,102}'::text[])))
  • Rows Removed by Filter: 430
4. 14.093 12,547.154 ↑ 81.5 250 1

Sort (cost=206,145.74..206,196.65 rows=20,364 width=89) (actual time=12,547.107..12,547.154 rows=250 loops=1)

  • Sort Key: (sum(f_cbus_store_summary_brand_2019_01_08_15_53_18.pod_ty)), s.store_src_cd
  • Sort Method: top-N heapsort Memory: 60kB
5. 54.358 12,533.061 ↓ 1.1 23,165 1

HashAggregate (cost=204,825.56..205,029.20 rows=20,364 width=85) (actual time=12,522.545..12,533.061 rows=23,165 loops=1)

  • Group Key: s.store_src_cd, s.store_cd, s.store_name, s.store_number, s.addr_01_dsc, s.city_dsc, s.state_cd, s.postal_cd, s.unsold
6. 8,790.497 12,478.703 ↓ 1.4 28,232 1

Nested Loop Left Join (cost=472.74..204,316.46 rows=20,364 width=85) (actual time=21.565..12,478.703 rows=28,232 loops=1)

  • Join Filter: ((COALESCE(f_cbus_store_summary_brand_2019_01_08_15_53_18.hier_id, sd.hier_id) = sd.hier_id) AND ((COALESCE(f_cbus_store_summary_brand_2019_01_08_15_53_18.entity_01_cd, sd.entity_01_cd))::text = (sd.entity_01_cd)::text) AND ((COALESCE(f_cbus_store_summary_brand_2019_01_08_15_53_18.brand_cd, sd.brand_cd))::text = (sd.brand_cd)::text) AND ((sd.store_src_cd)::text = (s.store_src_cd)::text))
  • Rows Removed by Join Filter: 18096078
7. 27.806 413.294 ↓ 1.4 28,232 1

Hash Left Join (cost=472.16..202,928.08 rows=20,364 width=100) (actual time=20.281..413.294 rows=28,232 loops=1)

  • Hash Cond: ((s.store_src_cd)::text = (f_cbus_store_summary_brand_2019_01_08_15_53_18.store_src_cd)::text)
8. 23.006 369.381 ↓ 1.1 23,165 1

Nested Loop (cost=382.83..202,304.18 rows=20,364 width=81) (actual time=4.167..369.381 rows=23,165 loops=1)

9. 15.253 43.709 ↓ 1.1 23,282 1

Nested Loop (cost=382.27..25,748.30 rows=20,364 width=81) (actual time=4.129..43.709 rows=23,282 loops=1)

10. 0.007 0.130 ↑ 1.0 1 1

HashAggregate (cost=0.02..0.03 rows=1 width=78) (actual time=0.129..0.130 rows=1 loops=1)

  • Group Key: (hierar_2.level_04_cd)::text
11. 0.123 0.123 ↓ 3.0 3 1

CTE Scan on hierar hierar_2 (cost=0.00..0.02 rows=1 width=78) (actual time=0.019..0.123 rows=3 loops=1)

12. 25.609 28.326 ↓ 1.1 23,282 1

Bitmap Heap Scan on v_ws_store s (cost=382.25..25,544.63 rows=20,364 width=84) (actual time=3.995..28.326 rows=23,282 loops=1)

  • Recheck Cond: ((market_cd)::text = (hierar_2.level_04_cd)::text)
  • Heap Blocks: exact=8444
13. 2.717 2.717 ↓ 1.1 23,407 1

Bitmap Index Scan on v_ws_store_market_cd_idx (cost=0.00..377.16 rows=20,364 width=0) (actual time=2.717..2.717 rows=23,407 loops=1)

  • Index Cond: ((market_cd)::text = (hierar_2.level_04_cd)::text)
14. 23.282 302.666 ↑ 1.0 1 23,282

Limit (cost=0.56..8.65 rows=1 width=8) (actual time=0.013..0.013 rows=1 loops=23,282)

15. 279.384 279.384 ↑ 1.0 1 23,282

Index Only Scan using x_store_entity_2018_12_20_02_12_00_pk on x_store_entity_2018_12_20_02_12_00 x_store_entity_2018_12_19_12_36_17 (cost=0.56..8.65 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=23,282)

  • Index Cond: ((store_src_cd = (s.store_src_cd)::text) AND (opco_cd = '101'::text))
  • Filter: ((entity_01_cd)::text = ANY ('{2224422,2224419,2224418}'::text[]))
  • Rows Removed by Filter: 0
  • Heap Fetches: 4
16. 3.336 16.107 ↓ 434.1 8,248 1

Hash (cost=89.10..89.10 rows=19 width=27) (actual time=16.107..16.107 rows=8,248 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 484kB
17. 3.724 12.771 ↓ 434.1 8,248 1

Nested Loop (cost=0.59..89.10 rows=19 width=27) (actual time=0.136..12.771 rows=8,248 loops=1)

18. 0.002 0.005 ↓ 3.0 3 1

HashAggregate (cost=0.02..0.03 rows=1 width=4) (actual time=0.005..0.005 rows=3 loops=1)

  • Group Key: hierar.hier_id
19. 0.003 0.003 ↓ 3.0 3 1

CTE Scan on hierar (cost=0.00..0.02 rows=1 width=4) (actual time=0.001..0.003 rows=3 loops=1)

20. 9.042 9.042 ↓ 144.7 2,749 3

Index Scan using f_cbus_store_summary_brand_2019_01_08_15_53_18_pk on f_cbus_store_summary_brand_2019_01_08_15_53_18 (cost=0.57..88.87 rows=19 width=27) (actual time=0.059..3.014 rows=2,749 loops=3)

  • Index Cond: (((time_period_cd)::text = 'FYTD'::text) AND (hier_id = hierar.hier_id) AND ((brand_cd)::text = '604'::text) AND ((entity_01_cd)::text = ANY ('{2224422,2224419,2224418}'::text[])))
21. 3,274.295 3,274.912 ↓ 213.7 641 28,232

Materialize (cost=0.58..13.82 rows=3 width=24) (actual time=0.000..0.116 rows=641 loops=28,232)

22. 0.249 0.617 ↓ 213.7 641 1

Nested Loop (cost=0.58..13.80 rows=3 width=24) (actual time=0.054..0.617 rows=641 loops=1)

23. 0.003 0.005 ↓ 3.0 3 1

HashAggregate (cost=0.02..0.03 rows=1 width=4) (actual time=0.005..0.005 rows=3 loops=1)

  • Group Key: hierar_1.hier_id
24. 0.002 0.002 ↓ 3.0 3 1

CTE Scan on hierar hierar_1 (cost=0.00..0.02 rows=1 width=4) (actual time=0.001..0.002 rows=3 loops=1)

25. 0.363 0.363 ↓ 71.3 214 3

Index Only Scan using mv_ws_store_brand_last_ship_pk on mv_ws_store_brand_last_ship sd (cost=0.56..13.74 rows=3 width=24) (actual time=0.017..0.121 rows=214 loops=3)

  • Index Cond: ((hier_id = hierar_1.hier_id) AND (brand_cd = '604'::text) AND (entity_01_cd = ANY ('{2224422,2224419,2224418}'::text[])))
  • Heap Fetches: 0