Subscribe to Posts by Email

Subscriber Count

    696

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Do not want bind peeking? what you have in then? _optim_peek_user_binds=false vs. /*+ NO_BIND_AWARE */

Adaptive cursor sharing introduced in 11g R1 to address the bind peeking issues with things track especially the bind aware and bind sensitivity. This is for plan stability right,

Read here more on this.

Can this stability when bind peeking issues is be achievable in 10g, well the obvious answer is sql profiles, stored out lines.

Another option is to disable the bind peeking using the hidden parameter _optim_peek_user_binds=false

But this may have side affects as you are turning off for entire instance, what if and how you want to disable the bind peeking for only single statement,

 

Well according to the document 740052.1, you can get the same consistent behavior (plan stability)  in 10g using the following optimizer hint without sql profiles or outlines if you are experiencing bind peeking issues.

/*+ NO_BIND_AWARE */

Example:-

SQL> variable lv_id number;
SQL> exec :lv_id :=10;
PL/SQL procedure successfully completed.

SQL> Select count(*) from sh.sales where prod_id = :lv_id;
COUNT(*)
----------
0
----if the bind values are peeked, we would see records in V$SQL_CS_STATISTICS:

SQL> Select address, child_number, peeked, executions from v$sql_cs_statistics;
ADDRESS CHILD_NUMBER P EXECUTIONS
-------- ------------ - ----------
cysh98920 0 Y 1

Now, let's turn off bind peeking using this hint
=============================


SQL> alter system flush shared_pool;
System altered.

SQL> exec :lv_id :=100;
PL/SQL procedure successfully completed.

SQL> Select /*+ NO_BIND_AWARE */ count(*) from sh.sales where prod_id = :lv_id;
COUNT(*)
----------
0
----With the above hint, the sql is not bind aware, therefore we don't see any records in v$SQL_CS_STATISTICS view.

SQL> Select address, child_number, peeked, executions from v$sql_cs_statistics;
no rows selected
SQL>

 

See your bind value is not peeked this time. So /*+ NO_BIND_AWARE */  is alternative for your _optim_peek_user_binds=false

-Thanks

Geek DBA

2 comments to Do not want bind peeking? what you have in then? _optim_peek_user_binds=false vs. /*+ NO_BIND_AWARE */

  • Jamsher

    Hi Geek DBA,

    If i set _optim_peek_user_binds=false at db level. So every sql using bind variable will go with hard parse ?. How optimizer will create execution plan.

    Thanks
    Jamsher

    • ketandba

      Bind peeking will be disabled where ever it uses the same plan for different bind variables, not exactly the hard parsing for every statement, but yes where it comes to use bind variables it will not peek.