How to decide good plan or bad plan

  • The optimized plan can be different according to the following factors.
    • Bind input can be checked in sqlhc_*_SQL_ID_13_all_bind_values.txt which is one of sqlhc outputs.
      • Between :b1 and :b2 : When the range of input is wide, the sub-optimized plan can be selected.
      • IN (:b1, ...:bn) : Too many IN bind variable inputs can make the SQL use sub-optimized plan.
      • Like :b1 : Unselective bind input such as '%A%' can cause the sub-optimized plan.
      • CONTAINS ( PartyEO.PARTY_NAME,  :B1, 1) > 0 : When :B1 is unselective, sub-optimized plan can be followed.
      • tab.col = NVL(:b1, tab.col) : When :b1 is null, sub-optimized plan can be used.
      • tab.col = DECODE(:b1,null,tab.col, :b1) : When :b1 is null, sub-optimized plan can be used.
      • etc.
    • VPD
      • Even if current cursor doesn't have VPD (DSP), there is no guarantee that another will work without VPD (DSP).
      • => Reduce the complexity of VPD logic
      • => Restrict number of user.
    • Table volume access can be checked in sma_[SQL_ID].sql rows. 
      • If the SQL uses too many rows in the global temporary table or the pl/sql table, the SQL can use some full table scan with hash join.
      • => Use reasonable number of rows per execution during the process.
      • => Avoid inconsistent volume per execution, if possible.
  • The plan (phv) should not have met the error. The error can be found in gv$sql_monitor or dba_hist_reports.
  • Conclusion
    • Use selective bind input
    • Minimize usage of VPD
    • Minimize data in global temporary table and pl/sql table in the SQL.
    • And then select Plan Hash Value for your purpose and pin it via sqlprofile.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值