Re: Why we should use bind variables when we write code......

  • From: "Dennis Williams" <oracledba.williams@xxxxxxxxx>
  • To: Mark.Bobak@xxxxxxxxxxxxxxx
  • Date: Tue, 19 Sep 2006 18:24:41 -0500


Basically Oracle "tries" to share SQL statements all the time. So when it
gets a new SQL statement, it first creates a checksum and compares that
checksum with each of the SQL statements in the buffer to try to find a
match, an exercise in futility with non-binding code. Here is what I did
when I encountered your problem a few years ago, maybe others have better

1. Reduce SHARED_POOL as a quick fix. This means it has fewer statements to
attempt to compare with.

2. Scan V$SQL for the worst offenders. You'll see the same SQL statements
appear in the thousands, with just changed variables. Use some clever SQL
queries to pinpoint the worst of the worst.

3. Take the worst SQL statements and match them with the application. Then
beg the developers to locate the place where those SQL statements are
generated and change them to use bind variables.

That should get you past the crisis. Then you can work the larger issue of
training all the developers.

Dennis Williams

Other related posts: