7
Beyond security what is the advantage of using explicit transaction? In which situations is recommended?
7
Beyond security what is the advantage of using explicit transaction? In which situations is recommended?
7
In this mode, the server will ensure that all operations are performed within a transaction.
In general they are used so that the developer does not have to worry about the logic of transactional handling and has to repeat it throughout the code.
However, the trend is the degradation of performance, because transactions are more "expensive" from the computational point of view since the database needs to perform several additional checks and there is a greater probability of occurring Locks and deadlocks where the developer can predict.
Finally, the advantage is in relation to the ease of development at the cost of performance and possible Locks.
Leaves it to the developer to start and end transactions via commands:
BEGIN TRANS
COMMIT TRANS
ROLLBACK TRANS
The downside is that the developer needs to repeat the control logic at all points where transactions are needed.
On the other hand, this allows a fine-tuning of performance, minimizing use of transactions where it is not needed, Locks and deadlocks, and allows the developer to analyze cases of possible competition problems.
My recommendation is to always use explicit transactions manually delimiting where they will be needed.
When code alone performs atomic operations, transactions are not necessary. For example, when only one command is made INSERT
or UPDATE
or SELECT
.
However, when there is a sequence of operations, then one must initiate a transaction always encompassing as little code as possible in order to increase the efficiency of the database system to process competing requests.
5
Perks:
Disadvantages:
Recommended to use:
Browser other questions tagged sql
You are not signed in. Login or sign up in order to post.