explain.depesz.com

PostgreSQL's explain analyze made readable

Result: L1As : Optimization for: Optimization for: Optimization for: plan #hsir; plan #DbO0; plan #B5ZB

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 8.130 24.690 ↑ 355.8 45 1

HashAggregate (cost=7,526.35..7,886.62 rows=16,012 width=220) (actual time=24.533..24.690 rows=45 loops=1)

  • Output: bsl.bustructureid, bsd.level, pnl.nomenclatureid, pnl.level, sum(psd.marginfrsim), sum(CASE WHEN (purchaseprice1simarray2.simulatedsalesprice IS NOT NULL) THEN CASE WHEN (purchaseprice1simarray2.simulatedsalesprice < purchaseprice1simarray2.initialsalesprice) THEN 1 ELSE 0 END ELSE 0 END), sum(CASE WHEN (salespricesimarray2.simulatedsalesprice IS NOT NULL) THEN CASE WHEN (salespricesimarray2.simulatedsalesprice < salespricesimarray2.initialsalesprice) THEN 1 ELSE 0 END ELSE 0 END), sum(CASE WHEN (purchaseprice1simarray2.simulatedsalesprice IS NOT NULL) THEN CASE WHEN (purchaseprice1simarray2.simulatedsalesprice > purchaseprice1simarray2.initialsalesprice) THEN 1 ELSE 0 END ELSE 0 END), sum(CASE WHEN (salespricesimarray2.simulatedsalesprice IS NOT NULL) THEN CASE WHEN (salespricesimarray2.simulatedsalesprice > salespricesimarray2.initialsalesprice) THEN 1 ELSE 0 END ELSE 0 END), sum(psd.qtysim), sum(psd.revenuesim), sum(psd.revenuefrsim), sum(psd.marginsim), sum((psd.vatamountsim * (psd.qtysim)::numeric))
  • Group Key: bsl.bustructureid, bsd.level, pnl.nomenclatureid, pnl.level
  • Buffers: shared hit=8,752
2. 0.014 16.560 ↑ 1.6 10,032 1

Hash Join (cost=1,027.87..6,725.75 rows=16,012 width=181) (actual time=1.062..16.560 rows=10,032 loops=1)

  • Output: bsl.bustructureid, bsd.level, pnl.nomenclatureid, pnl.level, psd.marginfrsim, purchaseprice1simarray2.simulatedsalesprice, purchaseprice1simarray2.initialsalesprice, salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice, psd.qtysim, psd.revenuesim, psd.revenuefrsim, psd.marginsim, psd.vatamountsim
  • Hash Cond: (psd.bustructureid = bsl.buid)
  • Buffers: shared hit=8,752
3. 1.592 16.275 ↓ 1.0 5,016 1

Gather (cost=1,000.72..6,472.11 rows=4,832 width=177) (actual time=0.783..16.275 rows=5,016 loops=1)

  • Output: psd.marginfrsim, psd.qtysim, psd.revenuesim, psd.revenuefrsim, psd.marginsim, psd.vatamountsim, psd.bustructureid, pnl.nomenclatureid, pnl.level, salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice, purchaseprice1simarray2.simulatedsalesprice, purchaseprice1simarray2.initialsalesprice
  • Workers Planned: 1
  • Workers Launched: 1
  • Buffers: shared hit=8,744
4. 0.719 14.683 ↑ 1.1 2,508 2 / 2

Nested Loop (cost=0.72..4,988.91 rows=2,842 width=177) (actual time=0.087..14.683 rows=2,508 loops=2)

  • Output: psd.marginfrsim, psd.qtysim, psd.revenuesim, psd.revenuefrsim, psd.marginsim, psd.vatamountsim, psd.bustructureid, pnl.nomenclatureid, pnl.level, salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice, purchaseprice1simarray2.simulatedsalesprice, purchaseprice1simarray2.initialsalesprice
  • Buffers: shared hit=8,744
  • Worker 0: actual time=0.129..17.354 rows=2,238 loops=1
  • Buffers: shared hit=3,883
5. 0.345 3.514 ↑ 1.2 418 2 / 2

Nested Loop (cost=0.28..1,445.15 rows=492 width=169) (actual time=0.041..3.514 rows=418 loops=2)

  • Output: psd.marginfrsim, psd.qtysim, psd.revenuesim, psd.revenuefrsim, psd.marginsim, psd.vatamountsim, psd.productid, psd.bustructureid, salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice, purchaseprice1simarray2.simulatedsalesprice, purchaseprice1simarray2.initialsalesprice
  • Buffers: shared hit=1,184
  • Worker 0: actual time=0.055..3.916 rows=373 loops=1
  • Buffers: shared hit=505
6. 0.574 3.169 ↑ 1.2 418 2 / 2

Nested Loop (cost=0.28..1,435.30 rows=492 width=137) (actual time=0.036..3.169 rows=418 loops=2)

  • Output: psd.marginfrsim, psd.qtysim, psd.revenuesim, psd.revenuefrsim, psd.marginsim, psd.vatamountsim, psd.purchaseprice1simarray, psd.productid, psd.bustructureid, salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice
  • Buffers: shared hit=1,184
  • Worker 0: actual time=0.050..3.605 rows=373 loops=1
  • Buffers: shared hit=505
7. 2.177 2.177 ↑ 1.2 418 2 / 2

Parallel Index Scan using price_strategy_detail_2094_pk on pricing.price_strategy_detail_2094 psd (cost=0.28..1,425.46 rows=492 width=482) (actual time=0.023..2.177 rows=418 loops=2)

  • Output: psd.productid, psd.bustructureid, psd.nomenclatureid, psd.bulevel, psd.nomenclatureparentid, psd.startpromodate, psd.endpromodate, psd.qtysimarray, psd.qtysim, psd.qty, psd.vatrate, psd.promosalesprice, psd.vatamountsim, psd.vatamount, psd.targetmarginrate, psd.stockqty, psd.marginfrgap, psd.ismodified, psd.ismodifiedfr, psd.margin, psd.marginfr, psd.marginfrrate, psd.marginfrratesim, psd.marginfrsim, psd.margingap, psd.marginrate, psd.marginrategap, psd.marginratesim, psd.marginsim, psd.revenue, psd.revenuefr, psd.revenuefrgap, psd.revenuefrsim, psd.revenuegap, psd.revenuesim, psd.unitmargin, psd.unitmargingap, psd.unitmarginsim, psd.avgcompsalesprice, psd.elasticitycoeff, psd.minsalesprice, psd.maxsalesprice, psd.mincompsalesprice, psd.maxcompsalesprice, psd.oldpurchaseprice2, psd.compnb, psd.oldpurchaseprice, psd.purchaseprice1sim, psd.purchaseprice2, psd.isalignable, psd.iscomp, psd.purchaseprice1, psd.svap, psd.priceindexsim, psd.priceindex, psd.svapfr, psd.analysisaxisarray, psd.detention, psd.salespricegap, psd.purchaseprice1simarray, psd.salesprice, psd.salespricegappct, psd.salespricepromoincl, psd.salespricepromoinclsim, psd.salespricesim, psd.salespricesimarray, psd.databucomparray, psd.databannercomparray, psd.ispricemodifiable, psd.internalarray, psd.pv_hyper, psd.pv_enseigne
  • Filter: (psd.bulevel = 3)
  • Rows Removed by Filter: 238
  • Buffers: shared hit=1,184
  • Worker 0: actual time=0.035..2.705 rows=373 loops=1
  • Buffers: shared hit=505
8. 0.418 0.418 ↑ 1.0 1 836 / 2

Function Scan on pg_catalog.jsonb_to_record salespricesimarray2 (cost=0.00..0.01 rows=1 width=64) (actual time=0.001..0.001 rows=1 loops=836)

  • Output: salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice
  • Function Call: jsonb_to_record((psd.salespricesimarray)[8])
  • Worker 0: actual time=0.001..0.001 rows=1 loops=373
9. 0.000 0.000 ↑ 1.0 1 836 / 2

Function Scan on pg_catalog.jsonb_to_record purchaseprice1simarray2 (cost=0.00..0.01 rows=1 width=64) (actual time=0.000..0.000 rows=1 loops=836)

  • Output: purchaseprice1simarray2.simulatedsalesprice, purchaseprice1simarray2.initialsalesprice
  • Function Call: jsonb_to_record((psd.purchaseprice1simarray)[8])
  • Worker 0: actual time=0.000..0.000 rows=1 loops=373
10. 10.450 10.450 ↑ 1.0 6 836 / 2

Index Only Scan using product_nomenclature_link_perf_idx on pricing.product_nomenclature_link pnl (cost=0.43..7.14 rows=6 width=16) (actual time=0.009..0.025 rows=6 loops=836)

  • Output: pnl.productid, pnl.nomenclatureid, pnl.level, pnl.nomenclaturecode
  • Index Cond: (pnl.productid = psd.productid)
  • Heap Fetches: 5,016
  • Buffers: shared hit=7,560
  • Worker 0: actual time=0.012..0.035 rows=6 loops=373
  • Buffers: shared hit=3,378
11. 0.041 0.271 ↑ 1.5 314 1

Hash (cost=21.20..21.20 rows=476 width=12) (actual time=0.271..0.271 rows=314 loops=1)

  • Output: bsl.bustructureid, bsl.buid, bsd.level
  • Buckets: 1,024 Batches: 1 Memory Usage: 22kB
  • Buffers: shared hit=8
12. 0.088 0.230 ↑ 1.5 314 1

Hash Join (cost=8.05..21.20 rows=476 width=12) (actual time=0.117..0.230 rows=314 loops=1)

  • Output: bsl.bustructureid, bsl.buid, bsd.level
  • Inner Unique: true
  • Hash Cond: (bsl.bustructureid = bsd.bustructureid)
  • Buffers: shared hit=8
13. 0.074 0.074 ↑ 1.0 473 1

Seq Scan on pricing.bu_structure_link bsl (cost=0.00..11.88 rows=473 width=12) (actual time=0.013..0.074 rows=473 loops=1)

  • Output: bsl.bustructurecode, bsl.bustructureid, bsl.buid, bsl.level, bsl.creationdate, bsl.modificationdate, bsl.suppressiondate
  • Filter: (bsl.bustructurecode = 1)
  • Rows Removed by Filter: 97
  • Buffers: shared hit=5
14. 0.023 0.068 ↓ 1.0 158 1

Hash (cost=6.15..6.15 rows=152 width=12) (actual time=0.068..0.068 rows=158 loops=1)

  • Output: bsd.level, bsd.bustructureid, bsd.bustructurecode
  • Buckets: 1,024 Batches: 1 Memory Usage: 15kB
  • Buffers: shared hit=3
15. 0.045 0.045 ↓ 1.0 158 1

Seq Scan on pricing.bu_structure_detail bsd (cost=0.00..6.15 rows=152 width=12) (actual time=0.008..0.045 rows=158 loops=1)

  • Output: bsd.level, bsd.bustructureid, bsd.bustructurecode
  • Filter: ((bsd.level >= 2) AND (bsd.bustructurecode = 1))
  • Rows Removed by Filter: 59
  • Buffers: shared hit=3
Planning time : 0.898 ms
Execution time : 27.681 ms