Considerations for SQL Server Transaction Processing

Source: Internet
Author: User

During project development, we should be familiar with database transactions, but how can we use transactions well?

I would like to share some of the following notes with you:

1. For the business to be processed, the transaction operation time should be as short as possible. Keeping the transaction open will lock the resource for a long period of time, which will block other users from performing operations or reading data.

2. Minimize the resources locked by transactions. For example, only tables related to the transactions performed by the demon are updated. If data modifications are logically dependent on each other, they should belong to the same transaction. Otherwise, irrelevant updates should be in their own transactions.

3. Only add related T-SQL operations to the transaction. Do not add additional searches or updates that are irrelevant to a transaction. Executing the SELECT statement in a transaction locks the associated table, which causes other users/sessions to be unable to execute or read data.

4. Do not open new things that need to wait for the user or external feedback in the transaction. Opening a transaction will lock the resource, and user feedback may need to be completed for a certain period of time. Therefore, user feedback should be collected before transactions are displayed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.