Sometimes there may be noticed unusual Oracle 11g behavior – by some not obvious reasons the magic Adaptive/Extended Cursor Sharing is not used. And this can happen exactly where execution plan changes are required for better SQL with new set of binds performance. From Oracle Optimizer team we know that Bind Aware Cursor Sharing (BASC) is complex technology which consists of couple of consequential applying Adaptive Cursor Sharing (ACS) and Extended Cursor Sharing (ECS) technologies:
“How does ACS work?
- Monitor queries where ECS is applicable (binds were peeked, predicate shape)
- Identify queries with variable data volume
- Enable ECS for these queries”
In MOS Adaptive Cursor Sharing Overview [ID 740052.1] can be found a list of preventing ECS usage conditions:
If any of the following checks fail ECS will be disabled :
- Extended cursor sharing is disabled
- The query has no binds
- Parallel query is used
- Certain parameters like (“bind peeking”=false) are set
- Hints are in use
- Outlines are being used
- It is a recursive query
- The number of binds in a given sql statement are greater than 14
What we have to do if all conditions were complied and ECS still doesn’t work? Initial problem was successfully resolved by adding /*+ BIND_AWARE*/ hint into query – according to Bug 9532657:
For cursors where one knows it wants to be bind aware then add a /*+ BIND_AWARE */ hint. This makes the cursor aware of bind values rather than automatically trying to work out …
– fortunately, there was possibility to change the query text in our case.
But questions remain: how to force or forbid BACS technology usage on system / session / single query level?
On RUOUG conference I presented simple SQL*Plus demonstration of Bind Aware Cursor Sharing (as well as closely linked Cardinality Feedback) elements on Oracle 188.8.131.52. This note explains some interesting test results