HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to Limit DTU Percentage Consumption for a Given Session in Azure SQL Database?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqllimitdtudatabaseazureforsessionhowgivenpercentage

Problem

We have an Azure SQL Database tier S4 (200 DTU), and there is one big table inside

When I run a "alter index rebuild..." statement, it takes about 18 mins to complete

This particular nonclustered index is 5 Gb in size, and during those 18 minutes of rebuilding, it takes all 100% of DTU available to this database
Of course, this is impacting other applications that are trying to work with this database

Question:

How can we limit available resources for a given session that runs a rebuild ?
Say, we want to make it use only 50%-60% of Database's DTUs, but not 100%


Is this possible on Azure SQL Database ?

Regards,

Solution

Have you considered using the Resumable Online Index Rebuild feature so you can schedule X executions of one minute of those indexes?

ALTER INDEX [ix_CustomerIDs]
ON [ContosoSales].[ConstosoTransactionData]
REBUILD
WITH (ONLINE = ON, RESUMABLE = ON, MAX_DURATION = 1 MINUTES);
GO

ALTER INDEX ix_CustomerIDs ON [ContosoSales].[ConstosoTransactionData] PAUSE

ALTER INDEX ix_CustomerIDs ON [ContosoSales].[ConstosoTransactionData] RESUME


Have you considered to scale up the tier to Premium to speed up things when performing index maintenance during any small maintenance window? You will pay Premium for just the hour where you scaled up and users may perceive less performance impact.

Code Snippets

ALTER INDEX [ix_CustomerIDs]
ON [ContosoSales].[ConstosoTransactionData]
REBUILD
WITH (ONLINE = ON, RESUMABLE = ON, MAX_DURATION = 1 MINUTES);
GO

ALTER INDEX ix_CustomerIDs ON [ContosoSales].[ConstosoTransactionData] PAUSE

ALTER INDEX ix_CustomerIDs ON [ContosoSales].[ConstosoTransactionData] RESUME

Context

StackExchange Database Administrators Q#210948, answer score: 3

Revisions (0)

No revisions yet.