Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Auto-generated UPDATE/High Version count due to bind_mismatch/waits on 'cursor: mutex X' and 'cursor

Vsevolod AfanassievSep 29 2017 — edited Oct 3 2017

11.2 on Linux

The application is written in Java and uses Java programming framework where UPDATE statements are auto-generated. This means that every column gets updated and the values come from bind variables. So a table with 50 columns gets an UPDATE statement with 50 bind variables.

UPDATE TABLE_A SET COLUMN1 = :1, COLUNM2 = :2, COLUMN3 = :3 ... WHERE COLUMN0 = :50

This UPDATE gets high version count due to bind_mismatch as determined from v$sql_shared_cursor: there are

about 1000 child cursors for this UPDATE.

High version count leads to waits on 'cursor: mutex X' and 'cursor: mutex S'. The waits are significant, with dozens of sessions waiting on these events, all for this UPDATE. I've tried flushing this cursor using dbms_shared_pool.purge and it didn't work. Flushing the entire shared pool with ALTER SYSTEM FLUSH SHARED_POOL works but may have its own side effects.

For bind mismatch to occur a bind variable needs to be re-defined between executions:

http://www.toadworld.com/platforms/oracle/b/weblog/archive/2016/09/26/why-my-execution-plan-has-not-been-shared-part-iii

And this is exactly what I am seeing in V$SQL_BIND_CAPTURE: the same bind variable may be defined either as VARCHAR2(32) or VARCHAR2(128) or VARCHAR2(2000). As there are so many bind variables there are many combinations and we get high version count.

What could be done about it other than changing the application?

This post has been answered by Jonathan Lewis on Sep 30 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2017
Added on Sep 29 2017
15 comments
4,046 views