Query gets slow when bind peeking is turned on

oracleperformancequery-performance

There is an old database that was upgraded from Oracle 10 to 11G R1. In Oracle 10 we had disabled bind peeking. Since Oracle 11 has adaptive cursor sharing, we want to turn bind peeking back on. When we did this we found that many queries went much much faster. Unfortunately, one critical query got very slow. As soon as we turn off bind peeking, the one query gets fast again but everything else goes back to being sluggish.

The question is: In Oracle 11, what would cause bind peeking to make a query slow? I thought adaptive cursor sharing was supposed to take care of the bad bind variable peeks problem.

Best Answer

Bind peeking is done in stages. First the query is be flagged as "bind sensitive" based on histograms, and then it may become "bind aware". The IS_BIND_SENSITIVE and IS_BIND_AWARE columns in V$SQL will show the state of the query. If IS_BIND_AWARE is not on, the query is not adapting.

This post helps to explains the process.