1

I'm administering an Oracle 12c database and need to understand how the database handles the execution order of DML (Data Manipulation Language) statements when executed across different transactions initiated by distinct connections.

Here’s the specific scenario I'm dealing with:

Transaction 1: Connection A initiates a transaction and executes a series of identical UPDATE statements:

update my_table set col1 = val2 where primary_key = 1;
update my_table set col1 = val2 where primary_key = 2;
...
update my_table set col1 = val2 where primary_key = 50;

Transaction 2: Connection B starts a transaction almost simultaneously, executing the same series of UPDATE statements in the same order.

Questions:

  1. Execution Order: Will Oracle 12c ensure that these UPDATE statements are executed in the same order across both transactions?

  2. Influencing Factors: What factors could influence the execution order of these DML statements across different transactions and connections?

I've reviewed the Oracle 12c documentation, particularly on transaction management and DML execution, but couldn’t find clear guidance on whether Oracle guarantees consistent execution order in such scenarios. I would appreciate any insights, particularly on how Oracle handles transaction scheduling or any internal optimizations that might affect the execution order

1 Answer 1

1

Will Oracle 12c ensure that these UPDATE statements are executed in the same order across both transactions?

Not sure what you mean by "across both transactions". Statements will be executed in the same order within each transaction, but statements executed in concurrent sessions generally will be interleaved in an undetermined fashion. That would be a moot point in your case, because the session that starts slightly later will block as soon as it hits the first row updated by the other session, until that other session commits.

1
  • Thanks for your response! Just to clarify, I'm looking to ensure that within a single transaction, Oracle 12c guarantees that DML statements are executed in the exact order they appear. My goal is to maintain the same order of locking across DML statements in parallel transactions to prevent deadlocks. I understand that the application design might need to change, but within this scope, I'm focusing on ensuring consistent locking order to avoid potential deadlocks
    – Idan Damri
    Commented Aug 23 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.