This article is a mirror article of machine translation, please click here to jump to the original article.

View: 4|Reply: 1

[Communication] SQL Server adds indexes in production

[Copy link]
Posted on10 minutes ago | | |
Requirements: If there is a table with tens of millions of data, it is necessary to add a non-aggregated index to the table to improve query efficiency, but the database is already running in the production environment, and many applications are performing adding, deleting, modifying, and querying operations on the table, which also means that multiple threads are performing operations on the table. If you use a normal index addition statement directly on the table, it will cause the program execution in the production environment to be abnormal, such as blocking and execution timeout.

The normal SQL statement to add a non-clustered index is as follows:

The security optimized SQL statement for adding non-clustered indexes is as follows:

Interpretation:

ONLINE = ON Role: Allows users to query, insert, update, and delete tables (i.e., "online" operations) during index creation, supported only by Enterprise Edition.
SORT_IN_TEMPDB = ON Function: Transfer the "temporary sorting data" needed for index creation/reconstruction from your business database to tempdb, not in the business database I am working on.
MAXDOP = 4 Role: Specifies MAXDOP to limit parallelism to ensure that it does not occupy all schedulers, i.e., to limit the index operation to perform in parallel with up to 4 CPU cores (threads).

Reference:

The hyperlink login is visible.
The hyperlink login is visible.




Previous:.NET/C# Developer's Swiss Army Knife LINQPad 9 Purchase Tutorial
 Landlord| Posted on8 minutes ago |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com