What are the ways to code efficient transactions?

What are the ways to code efficient transactions?

- We shouldn't allow input from users during a transaction.
- We shouldn't open transactions while browsing through data.
- We should keep the transaction as short as possible.
- We should try to use lower transaction isolation levels.
- We should access the least amount of data possible while in a transaction.

What are the ways to code efficient transactions?

Some ways and guidelines to code efficient transactions:
- Do not ask for an input from a user during a transaction.
- Get all input needed for a transaction before starting the transaction.
- Transaction should be atomic
- Transactions should be as short and small as possible.
- Rollback a transaction if a user intervenes and re-starts the transaction.
- Transaction should involve a small amount of data as it needs to lock the number of rows involved.
- Avoid transactions while browsing through data.
Differences among batches, stored procedures & triggers
SQL server Batches, stored procedures & triggers - A batch is a group of one or more SQL statements. SQL Server compiles the statements of a batch......
What are the instances when triggers are appropriate?
Scenarios for using triggers. To create a audit log of database activity. To apply business rules. To apply some calculation on data from tables which is not stored in them.....
What are the restrictions applicable while creating views?
Views can be created referencing tables and views only in the current database. ......
Post your comment