Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AUTONOMOUS_TRANSACTION

Tags:

sql

oracle

plsql

I was thinking of using AUTONOMOUS_TRANSACTION Pragma for some logging in a batch process. Does anyone have any experience with this ? If so any pros and cons would be appreciated.

like image 494
berlebutch Avatar asked Aug 26 '09 14:08

berlebutch


1 Answers

IMO Autonomous Transactions are particularly adapted to logging: they run independently from the main session, meaning you can write in a table, commit or rollback changes without affecting the main transaction.

They also add little overhead: if you run big statements and add an autonomous transaction between each statement the performance cost will be negligible.

There is also a side-effect that you may find interesting: since the autonomous transactions are in independant sessions from the calling transaction, you can follow the progression of your main process as it is running. You don't have to wait for the main transaction to finish: you can query the logging table as it is filled by the autonomous transactions.

like image 183
Vincent Malgrat Avatar answered Sep 23 '22 05:09

Vincent Malgrat