Configure Parallel Index Operations - SQL Server (2024)

  • Article

Applies to: Configure Parallel Index Operations - SQL Server (1) SQL Server Configure Parallel Index Operations - SQL Server (2) Azure SQL Database Configure Parallel Index Operations - SQL Server (3) Azure SQL Managed Instance

This topic defines max degree of parallelism and explains how to modify this setting in SQL Server by using SQL Server Management Studio or Transact-SQL.

On multiprocessor systems that are running SQL Server Enterprise or higher, index statements may use multiple processors (CPUs) to perform the scan, sort, and index operations associated with the index statement just like other queries do. The number of CPUs used to run a single index statement is determined by the max degree of parallelism server configuration option, the current workload, and the index statistics. The max degree of parallelism option determines the maximum number of processors to use in parallel plan execution. If the SQL Server Database Engine detects that the system is busy, the degree of parallelism of the index operation is automatically reduced before statement execution starts. The Database Engine can also reduce the degree of parallelism if the leading key column of a non-partitioned index has a limited number of distinct values or the frequency of each distinct value varies significantly. For more information, see Query Processing Architecture Guide.

Note

Parallel index operations are not available in every SQL Server edition. For more information, see Editions and supported features of SQL Server 2022.

In This Topic

Before You Begin

Limitations and Restrictions

  • The number of processors that are used by the query optimizer typically provides optimal performance. However, operations such as creating, rebuilding, or dropping very large indexes are resource intensive and can cause insufficient resources for other applications and database operations for the duration of the index operation. When this problem occurs, you can manually configure the maximum number of processors that are used to run the index statement by limiting the number of processors to use for the index operation.

  • The MAXDOP index option overrides the max degree of parallelism configuration option only for the query specifying this option. The following table lists the valid integer values that can be specified with the max degree of parallelism configuration option and the MAXDOP index option.

    ValueDescription
    0Specifies that the server determines the number of CPUs that are used, depending on the current system workload. This is the default value and recommended setting.
    1Suppresses parallel plan generation. The operation will be executed serially.
    2-64Limits the number of processors to the specified value. Fewer processors may be used depending on the current workload. If a value larger than the number of available CPUs is specified, the actual number of available CPUs is used.
  • Parallel index execution and the MAXDOP index option apply to the following Transact-SQL statements:

    • CREATE INDEX

    • ALTER INDEX (...) REBUILD

    • DROP INDEX (This applies to clustered indexes only.)

    • ALTER TABLE ADD (index) CONSTRAINT

    • ALTER TABLE DROP (clustered index) CONSTRAINT

  • The MAXDOP index option cannot be specified in the ALTER INDEX (...) REORGANIZE statement.

  • Memory requirements for partitioned index operations that require sorting can be greater if the Query Optimizer applies degrees of parallelism to the build operation. The higher the degrees of parallelism, the greater the memory requirement is. For more information, see Partitioned Tables and Indexes.

Permissions

Requires ALTER permission on the table or view.

Using SQL Server Management Studio

To set max degree of parallelism on an index

  1. In Object Explorer, click the plus sign to expand the database that contains the table on which you want to set max degree of parallelism for an index.

  2. Expand the Tables folder.

  3. Click the plus sign to expand the table on which you want to set max degree of parallelism for an index.

  4. Expand the Indexes folder.

  5. Right-click the index for which you want to set the max degree of parallelism and select Properties.

  6. Under Select a page, select Options.

  7. Select Maximum degree of parallelism, and then enter some value between 1 and 64.

  8. Click OK.

Using Transact-SQL

To set max degree of parallelism on an existing index

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    USE AdventureWorks2022; GO /*Alters the IX_ProductVendor_VendorID index on the Purchasing.ProductVendor table so that, if the server has eight or more processors, the Database Engine will limit the execution of the index operation to eight or fewer processors. */ ALTER INDEX IX_ProductVendor_VendorID ON Purchasing.ProductVendor REBUILD WITH (MAXDOP=8); GO 

For more information, see ALTER INDEX (Transact-SQL).

Specify max degree of parallelism when creating a new index

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    USE AdventureWorks2022; GO CREATE INDEX IX_ProductVendor_NewVendorID ON Purchasing.ProductVendor (BusinessEntityID) WITH (MAXDOP=8); GO 

See also

Query Processing Architecture Guide
CREATE INDEX (Transact-SQL)
ALTER INDEX (Transact-SQL)
DROP INDEX (Transact-SQL)
ALTER TABLE (Transact-SQL)
ALTER TABLE table_constraint (Transact-SQL)
ALTER TABLE index_option (Transact-SQL)

Configure Parallel Index Operations - SQL Server (2024)

FAQs

How do I create an index in parallel in SQL Server? ›

Using SQL Server Management Studio

Expand the Indexes folder. Right-click the index for which you want to set the max degree of parallelism and select Properties. Under Select a page, select Options. Select Maximum degree of parallelism, and then enter some value between 1 and 64.

What are parallel index operations? ›

Parallel Indexing is a very useful technique that allows the watchkeeper to react almost instantly to any deviation from the planned track and to constantly monitor whether the vessel is 'right of the track', 'left of the track' or 'on track'.

How to do parallel execution in SQL Server? ›

To achieve parallelism for SQL DML statements, you must first enable parallel DML in your session: ALTER SESSION ENABLE PARALLEL DML; Then any DML issued against a table with a parallel attribute will occur in parallel, if no PDML restrictions are violated.

What is the best setting for max degree of parallelism? ›

Setting MAXDOP to 2, 4, or 8 generally provides the best results in most use cases. We recommend that you test your workload and monitor for any parallelism-related wait types such as CXPACKET .

Can we create two indexes on same column in SQL Server? ›

Yes, you can do it. But either more indexes on a column or the use of a non-clustered index in a table may decrease the performance.

What is the degree of parallelism in SQL Server index? ›

So, what is the Max Degree of Parallelism option? This option in SQL Server lets SQL Server control the number of CPUs it can use to run T-SQL queries in parallel or to perform indexing tasks in parallel. By default, the value is zero which means that SQL Server can use infinite (all) CPUs for each query.

How do you implement parallel execution? ›

Parallel Testing using TestNG and Selenium
  1. Methods: Helps run methods in separate threads.
  2. Tests: Help to run all methods belonging to the same tag in the same thread.
  3. Classes: Helps to run all methods belonging to a class in a single thread.
  4. Instances: Helps run all methods in the same instance in the same thread.
Feb 10, 2023

How do I run two queries simultaneously in SQL Server? ›

To run a query with multiple statements, ensure that each statement is separated by a semicolon; then set the DSQEC_RUN_MQ global variable to 1 and run the query. When the variable is set to zero, all statements after the first semicolon are ignored.

How to check if a query is running in parallel in SQL Server? ›

If avg_wait_time shows a negative value, it's a parallel query. If you can execute the query on demand in SQL Server Management Studio (SSMS) or Azure Data Studio, run it with SET STATISTICS TIME ON and SET STATISTICS IO ON .

What is the #1 rule of parallelism? ›

In our first article on parallel structure, we gave you the basics—most importantly, the rule that governs parallel structure: When grouping related items in a single sentence, each item should grammatically mirror the others.

How to set degree of parallelism in SQL? ›

Use SQL Server Management Studio or Azure Data Studio
  1. In Object Explorer, right-click the desired instance and select Properties.
  2. Select the Advanced node.
  3. In the Max Degree of Parallelism box, select the maximum number of processors to use in parallel plan execution.
Jan 8, 2024

How to avoid parallelism in SQL Server? ›

It all depends on the execution plan of the query. If the query is having lots of CXPACKET waits due to parallelism, we can see whether setting MAXDOP to 1, will help the query. It needs to be tested before setting up this option.

How do I create a secondary index in SQL? ›

To add a secondary index to a table do one of the following:
  1. Add an INDEX clause to the end of a CREATE TABLE statement. INDEX clauses generally take the following form: INDEX {index_name} ({column_names}); ...
  2. Use a CREATE INDEX statement. CREATE INDEX statements generally take the following form:

How to create index on partitioned table in SQL? ›

Use the CREATE INDEX statement to create indexes on partitioned tables. To create an index for each partition, use the PARTITIONED clause. To create a single index that spans all partitions, use the NOT PARTITIONED clause. You can only create a partitioned Encoded Vector Index (EVI) over a partitioned table.

How do I create a multi column index in SQL? ›

Syntax. CREATE INDEX [index name] ON [Table name]([column1, column2, column3,...]); Multicolumn indexes can: be created on up to 32 columns.

How to create a composite index in SQL? ›

An index on two or more columns is called a composite index. For example, the following statement creates a two-column composite index: CREATE INDEX name ON Employees ( Surname, GivenName ); A composite index is useful if the first column alone does not provide high selectivity.

Top Articles
Simply Stacie Easy Peach Bread {Quick Bread Recipe}
Dutch Vegan Stamppot - Vegan Recipes - My Green Passion
Diario Las Americas Rentas Hialeah
Star Sessions Imx
Part time Jobs in El Paso; Texas that pay $15, $25, $30, $40, $50, $60 an hour online
Craigslist Parsippany Nj Rooms For Rent
Doublelist Paducah Ky
Green Bay Press Gazette Obituary
Palace Pizza Joplin
Mikayla Campinos Videos: A Deep Dive Into The Rising Star
Reddit Wisconsin Badgers Leaked
Local Dog Boarding Kennels Near Me
Where does insurance expense go in accounting?
Summer Rae Boyfriend Love Island – Just Speak News
I Wanna Dance with Somebody : séances à Paris et en Île-de-France - L'Officiel des spectacles
2016 Ford Fusion Belt Diagram
Byte Delta Dental
Nissan Rogue Tire Size
Navy Female Prt Standards 30 34
Prosser Dam Fish Count
Buy Swap Sell Dirt Late Model
Scotchlas Funeral Home Obituaries
Rugged Gentleman Barber Shop Martinsburg Wv
What Is Vioc On Credit Card Statement
Hdmovie 2
Poe Str Stacking
Busted Mcpherson Newspaper
Yonkers Results For Tonight
Lost Pizza Nutrition
Farm Equipment Innovations
Best Town Hall 11
Ewg Eucerin
Taktube Irani
Lucky Larry's Latina's
Santa Cruz California Craigslist
Craigslist Free Manhattan
R/Moissanite
Citibank Branch Locations In Orlando Florida
Sas Majors
If You're Getting Your Nails Done, You Absolutely Need to Tip—Here's How Much
M&T Bank
Rocket Lab hiring Integration & Test Engineer I/II in Long Beach, CA | LinkedIn
Join MileSplit to get access to the latest news, films, and events!
Julies Freebies Instant Win
Cvs Minute Clinic Women's Services
Strange World Showtimes Near Atlas Cinemas Great Lakes Stadium 16
Deviantart Rwby
Taterz Salad
Cognitive Function Test Potomac Falls
Les BABAS EXOTIQUES façon Amaury Guichon
E. 81 St. Deli Menu
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 5793

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.