Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Statistics very slow on a 3Tb database #798

Open
angry-sqldba opened this issue Mar 13, 2024 · 3 comments
Open

Update Statistics very slow on a 3Tb database #798

angry-sqldba opened this issue Mar 13, 2024 · 3 comments

Comments

@angry-sqldba
Copy link

Running update statistics on a 3Tb database is very slow

SQL server 2022 ENT
Last version of the script
Command:
EXECUTE dbo.IndexOptimize
@databases = 'ABC',
@FragmentationLow = NULL,
@FragmentationMedium = NULL,
@FragmentationHigh = NULL,
@UpdateStatistics = 'Index',
@OnlyModifiedStatistics = 'Y',
@LogToTable = 'Y',
@MSShippedObjects = 'Y',
@execute = 'N'

@angry-sqldba
Copy link
Author

running sp_updatestats takes just a few seconds (as the statistics are already up to date)

@angry-sqldba
Copy link
Author

I have found the issue.
commenting out the subquery related to the resumable index fixed the issue.

												`+ ',0 AS ResumableIndexOperation'`

                                               ` --+ ', ' + CASE WHEN @Version >= 14 THEN 'CASE WHEN EXISTS(SELECT * FROM sys.index_resumable_operations index_resumable_operations WHERE state_desc = ''PAUSED'' AND index_resumable_operations.object_id = indexes.object_id AND index_resumable_operations.index_id = indexes.index_id AND (index_resumable_operations.partition_number = partitions.partition_number OR index_resumable_operations.partition_number IS NULL)) THEN 1 ELSE 0 END' ELSE '0' END + ' AS ResumableIndexOperation'`

@wqweto
Copy link

wqweto commented Mar 15, 2024

Btw, can try dumping sys.index_resumable_operations into a temp #Tmp_index_resumable_operations table and base original query on it instead, to test if this speeds up performance on 3TB databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants