Mafiree logo
  • About
  • Services
  • Blogs
  • Careers
  • Products
    • orbit logo Orbit
    • streamer logo Xstreami
  • Contact
Schedule a Call
Menu
  • About
  • Services
  • Blogs
  • Careers
  • Products
    • orbit logo Orbit
    • streamer logo Xstreami
  • Contact
  • Schedule a Call
Database
Database Database Managed Services
MySQL MySQL
MySQL Consulting Services
MySQL Migration Services
MySQL Optimization & Query Tuning
MySQL Database Administration
MySQL Backup & Recovery
MySQL Security & Maintenance
MySQL Cloud Services (AWS RDS, Aurora, Google Cloud SQL, Azure)
MySQL for Ecommerce
MySQL High Availability & Replication
MongoDB MongoDB
MongoDB Consulting Services
MongoDB Migration Services
MongoDB Optimization & Query Tuning
MongoDB Database Administration
MongoDB Backup & Recovery
MongoDB Security & Maintenance
MongoDB Cloud (Atlas)
MongoDB Solutions by Industry
MongoDB High Availability & Replication
PostgreSQL PostgreSQL
PostgreSQL Consulting
PostgreSQL Migration & Upgrades
Performance Tuning & Query Optimization
PostgreSQL Administration & Managed Services
High Availability, Clustering & Replication
PostgreSQL Backup, Recovery & Disaster Planning
PostgreSQL Security, Compliance & Auditing
PostgreSQL for Analytics & Data Warehousing
PostgreSQL on Cloud & Containers
PostgreSQL Extensions & Open-Source Integrations
PostgreSQL for Every Industry
SQL Server MSSQL
MSSQL Consulting Services
MSSQL Migration Services
MSSQL Optimization & Query Tuning Services
MSSQL Database Administration Services
MSSQL Backup & Recovery Services
MSSQL High Availability & Replication Services
MSSQL Security & Compliance Services
MSSQL Performance Monitoring & Health Checks
MSSQL Solutions by Industry
Aerospike Aerospike
Aerospike Consulting Services
Aerospike Migration Services
Aerospike Performance Optimization & Tuning
Aerospike Database Administration
Aerospike Backup & Recovery
Aerospike High Availability
Aerospike Cloud & Hybrid Deployments
Aerospike for Real-Time Applications (AdTech, FinTech, Retail, IoT)
Analytics DB
Analytics DB Analytics DB Services
Clickhouse Clickhouse
ClickHouse Consulting Services
ClickHouse Migration Services
ClickHouse Optimization & Query Tuning
ClickHouse Database Administration
ClickHouse Backup & Recovery
ClickHouse Security & Maintenance
ClickHouse Cloud Services (ClickHouse Cloud, AWS, GCP, Azure)
ClickHouse Solutions by Industry
ClickHouse High Availability & Replication
TiDB TiDB
TiDB Consulting & Architecture Planning
TiDB Administration & Maintenance
TiDB Security and Privacy Maintenance
TiDB Performance & Query Optimization
TiDB Migration Services
TiDB Backup & Disaster Recovery
TiDB High Availability Solutions
TiDB Solutions by Industry
TiDB Cloud Services
ScyllaDB ScyllaDB
ScyllaDB Consulting & Architecture Planning
ScyllaDB Administration & Maintenance
ScyllaDB Security and Privacy Maintenance
ScyllaDB Performance & Query Optimization
ScyllaDB Migration Services
ScyllaDB Backup & Disaster Recovery
ScyllaDB High Availability Solutions
ScyllaDB Solutions by Industry
ScyllaDB Cloud Services
DevOps
DevOps DevOps Services
Version Control Version Control
Kubernetes Kubernetes
Infrastructure Infrastructure Management
Web Servers Web Servers
Networking
Networking Networking Services
Basic Basic
Advanced Advanced
MySQL MySQL
MongoDB MongoDB
PostgreSQL PostgreSQL
MSSQL MSSQL
Aerospike Aerospike
Clickhouse Clickhouse
TiDB TiDB
ScyllaDB ScyllaDB
Version Control Version Control
Kubernetes Kubernetes
Infrastructure Infrastructure Management
Web Servers Web Servers
Basic Basic
Advanced Advanced
MySQL Consulting Services
MySQL Migration Services
MySQL Optimization & Query Tuning
MySQL Database Administration
MySQL Backup & Recovery
MySQL Security & Maintenance
MySQL Cloud Services (AWS RDS, Aurora, Google Cloud SQL, Azure)
MySQL for Ecommerce
MySQL High Availability & Replication
MongoDB Consulting Services
MongoDB Migration Services
MongoDB Optimization & Query Tuning
MongoDB Database Administration
MongoDB Backup & Recovery
MongoDB Security & Maintenance
MongoDB Cloud (Atlas)
MongoDB Solutions by Industry
MongoDB High Availability & Replication
PostgreSQL Consulting
PostgreSQL Migration & Upgrades
Performance Tuning & Query Optimization
PostgreSQL Administration & Managed Services
High Availability, Clustering & Replication
PostgreSQL Backup, Recovery & Disaster Planning
PostgreSQL Security, Compliance & Auditing
PostgreSQL for Analytics & Data Warehousing
PostgreSQL on Cloud & Containers
PostgreSQL Extensions & Open-Source Integrations
PostgreSQL for Every Industry
MSSQL Consulting Services
MSSQL Migration Services
MSSQL Optimization & Query Tuning Services
MSSQL Database Administration Services
MSSQL Backup & Recovery Services
MSSQL High Availability & Replication Services
MSSQL Security & Compliance Services
MSSQL Performance Monitoring & Health Checks
MSSQL Solutions by Industry
Aerospike Consulting Services
Aerospike Migration Services
Aerospike Performance Optimization & Tuning
Aerospike Database Administration
Aerospike Backup & Recovery
Aerospike High Availability
Aerospike Cloud & Hybrid Deployments
Aerospike for Real-Time Applications (AdTech, FinTech, Retail, IoT)
ClickHouse Consulting Services
ClickHouse Migration Services
ClickHouse Optimization & Query Tuning
ClickHouse Database Administration
ClickHouse Backup & Recovery
ClickHouse Security & Maintenance
ClickHouse Cloud Services (ClickHouse Cloud, AWS, GCP, Azure)
ClickHouse Solutions by Industry
ClickHouse High Availability & Replication
TiDB Consulting & Architecture Planning
TiDB Administration & Maintenance
TiDB Security and Privacy Maintenance
TiDB Performance & Query Optimization
TiDB Migration Services
TiDB Backup & Disaster Recovery
TiDB High Availability Solutions
TiDB Solutions by Industry
TiDB Cloud Services
ScyllaDB Consulting & Architecture Planning
ScyllaDB Administration & Maintenance
ScyllaDB Security and Privacy Maintenance
ScyllaDB Performance & Query Optimization
ScyllaDB Migration Services
ScyllaDB Backup & Disaster Recovery
ScyllaDB High Availability Solutions
ScyllaDB Solutions by Industry
ScyllaDB Cloud Services
  1. Home
  2. > Blogs
  3. > SQL Server
  4. > How to Optimize SQL Server Performance: Implementing Online DDL

How to Optimize SQL Server Performance: Implementing Online DDL

SQL Server 2022 added the "Wait at Low Priority" option that allows index creation and alteration to wait for resources to become available before executing.

Chithambaresh May 06, 2024

Subscribe for email updates

Introduction:

Creating and Altering indexes for large tables can be a time-consuming process and may block other processes as well. However, with the introduction of the “Wait at Low Priority” that allows index creation to wait for resources to become available before executing. This feature reduces the impact on long-running queries that have a higher execution priority. In this blog post, we will explore the syntax and usage of this option, along with its limitations and potential benefits.

Understanding the Syntax:

To use the “Wait at Low Priority” option during index creation, the following syntax can be used:

CREATE CLUSTERED INDEX INDEX_NAME ON TABLENAME (COLUMNNAME) WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = X MINUTES, ABORT_AFTER_WAIT = NONE/SELF/BLOCKERS) ) );

Here’s a breakdown of the different components:

  • INDEX_NAME: Specifies the name of the index to be created.
  • TABLENAME: Denotes the table on which the index will be created.
  • COLUMNNAME: Represents the column(s) where the index will be applied.
  • ONLINE = ON: This option must be enabled to utilize the “Wait at Low Priority” feature. - -WAIT_AT_LOW_PRIORITY: This setting signifies the new option we are interested in.
  • MAX_DURATION: Allows you to specify the maximum waiting time in minutes for the operation
    to commence.
  • ABORT_AFTER_WAIT: Determines the action to take if the wait time exceeds the specified
    duration. The options are:
  1.  NONE: Waits for the lock with regular priority.
  2.  SELF: Exits the online index operation.
  3.  BLOCKERS: Kills transactions that are blocking the index rebuild.

Example:

To demonstrate how the “Wait at Low Priority” option can be used during index creation, consider the following example:

  1. CREATE NONCLUSTERED INDEX [test_idx] ON [dbo].[tblAuthors]
  2. (
  3.     [Id],
  4.     [Author_name] 
  5. )WITH (ONLINE = ON 
  6.         (WAIT_AT_LOW_PRIORITY 
  7.            (MAX_DURATION = 1 MINUTES, ABORT_AFTER_WAIT = SELF)
  8.         )
  9.      );
  10. GO

In this scenario, we are creating a non-clustered index named “test_idx” on the “tblAuthors” table, specifically on the “Id” and “Author_name” columns. The index creation will wait for a maximum duration of 1 minute, and if it exceeds this time, the operation will be aborted or the index will be created if the resource is available.

Maintenance with ALTER INDEX:

The “Wait at Low Priority” option can also be utilized during index maintenance tasks like rebuilding or reorganizing. The below syntax can be used for index REBUILD & REORGANIZE:

ALTER INDEX index_name ON table_name REBUILD WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = X MINUTES, ABORT_AFTER_WAIT = NONE/SELF/BLOCKERS) ) );

The components of this syntax are similar to the index creation syntax described earlier.

Limitations:

While the “Wait at Low Priority” option is a valuable feature, it does come with certain limitations.

The key points to consider are:

  • The ONLINE argument must be set to ON for this option to be available.
  • This functionality is only supported in the Enterprise and Developer editions of SQL Server 2022.

Conclusion:

The “Wait at Low Priority” option provides developers with a useful tool for managing index creation and maintenance operations. By leveraging this option, it becomes possible to prioritize these operations and make them more efficient.

Leave a Comment

Related Blogs

How MS SQL Server Manages Data at Rest and Data in Motion

Data at Rest refers to inactive data stored in databases, while Data in Motion is actively transmitted or processed between systems in SQL Server.

  1216 views
Resumable Operations for ALTER TABLE Constraints in SQL Server 2022

Empower Your Database Management with SQL Server 2022's Resumable Operations

  1923 views
Data File Splitting in SQL Server

Huge data blocks resides under single MDF file might cause a performance of the query and impact the application services. This blog help you to understand how we can the split the single MDF file into multiple data files.

  1564 views
SQL Server On Linux

SQL Server 2017 brings the best features of the Microsoft relational database engine to the enterprise Linux ecosystem, including SQL Server Agent, Azure Active Directory (Azure AD) authentication, best-in-class high availability/ disaster recovery, and unparalleled data security.

  2234 views
Achieving High Availability Using Log Shipping

Here we will get the detailed explanation of how we can achieve HA using Log Shipping.

  2810 views

Subscribe for email updates

Get in touch with us

Highlights

More than 6000 Servers Monitored

Happy Clients

Certified DBAs

24 x 7 x 365 Support

PCI

Database Services

MySQL MongoDB PostgreSQL SQL Server Aerospike Clickhouse TiDB MariaDB Columnstore

Quick Links

Careers Blog Contact Privacy Policy Disclaimer Policy

Contacts

Linkedin Mafiree Facebook Mafiree Twitter Mafiree

Nagercoil Office

Miru IT Park, Vallankumaranvillai,

Nagercoil, Tamilnadu - 629 002.

Bangalore Office

Unit 303, Vanguard Rise,

5th Main, Konena Agrahara,

Old Airport Road, Bangalore - 560 017.

Call: +91 6383016411

Email: sales@mafiree.com


Copyright © - All Rights Reserved - Mafiree