explain.depesz.com

PostgreSQL's explain analyze made readable

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

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 8.914 23.666 ↑ 355.8 45 1

HashAggregate (cost=7,526.35..7,886.62 rows=16,012 width=220) (actual time=23.505..23.666 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,750
2. 0.084 14.752 ↑ 1.6 10,032 1

Hash Join (cost=1,027.87..6,725.75 rows=16,012 width=181) (actual time=2.041..14.752 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,750
3. 1.841 14.028 ↓ 1.0 5,016 1

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

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

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

  • Output: psd.marginfrsim, psd.qtysim, psd.revenuesim, psd.revenuefrsim, psd.marginsim, psd.vatamountsim, psd.bustructureid, salespricesimarray2.simulatedsalesprice, salespricesimarray2.initialsalesprice, purchaseprice1simarray2.simulatedsalesprice, purchaseprice1simarray2.initialsalesprice, pnl.nomenclatureid, pnl.level
  • Buffers: shared hit=8,742
  • Worker 0: actual time=0.151..15.269 rows=1,896 loops=1
  • Buffers: shared hit=3,300
5. 0.376 3.258 ↑ 1.2 418 2 / 2

Nested Loop (cost=0.28..1,445.15 rows=492 width=169) (actual time=0.056..3.258 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,182
  • Worker 0: actual time=0.083..3.628 rows=316 loops=1
  • Buffers: shared hit=438
6. 0.648 2.882 ↑ 1.2 418 2 / 2

Nested Loop (cost=0.28..1,435.30 rows=492 width=137) (actual time=0.052..2.882 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,182
  • Worker 0: actual time=0.079..3.364 rows=316 loops=1
  • Buffers: shared hit=438
7. 1.816 1.816 ↑ 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.038..1.816 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,182
  • Worker 0: actual time=0.063..2.563 rows=316 loops=1
  • Buffers: shared hit=438
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=316
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=316
10. 8.360 8.360 ↑ 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.007..0.020 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=316
  • Buffers: shared hit=2,862
11. 0.091 0.640 ↑ 1.5 314 1

Hash (cost=21.20..21.20 rows=476 width=12) (actual time=0.640..0.640 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.205 0.549 ↑ 1.5 314 1

Hash Join (cost=8.05..21.20 rows=476 width=12) (actual time=0.268..0.549 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.185 0.185 ↑ 1.0 473 1

Seq Scan on pricing.bu_structure_link bsl (cost=0.00..11.88 rows=473 width=12) (actual time=0.021..0.185 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.057 0.159 ↓ 1.0 158 1

Hash (cost=6.15..6.15 rows=152 width=12) (actual time=0.159..0.159 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.102 0.102 ↓ 1.0 158 1

Seq Scan on pricing.bu_structure_detail bsd (cost=0.00..6.15 rows=152 width=12) (actual time=0.010..0.102 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 : 1.584 ms
Execution time : 26.551 ms