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

running rebuild on individual index takes a long time compared to native SQL commands #808

Open
stevetrinhwork opened this issue Jun 5, 2024 · 2 comments

Comments

@stevetrinhwork
Copy link

Description of the issue
I'm trying to run an index rebuild and comparing Ola commands vs native SQL commands and the time it takes to complete is significantly longer for Ola version.

SQL Server version and edition
Execute SELECT @@VERSION
Microsoft SQL Server 2019 (RTM-CU25-GDR) (KB5036335) - 15.0.4360.2 (X64) Mar 19 2024 00:23:01 Copyright (C) 2019 Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

Version of the script
Check the header of the stored procedure
Version: 2022-01-02 13:58:13

What command are you executing?
EXECUTE dbo.IndexOptimize
@databases = 'TE_3E_PROD',
@FragmentationLow = NULL,
@FragmentationMedium = 'INDEX_REBUILD_ONLINE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 20,
@indexes = 'TE_3E_PROD.dbo.CostBill.PK__CostBill__737B04B8',
@SortInTempdb = 'Y',
@LogToTable = 'Y'

ALTER INDEX [PK__CostBill__737B04B8] ON [dbo].[CostBill] REBUILD WITH (SORT_IN_TEMPDB = ON, ONLINE = ON, RESUMABLE = OFF)

What output are you getting?
This took a little over 9 minutes to run. See the time stamps.

Date and time: 2024-06-05 13:45:44
Version: 2022-01-02 13:58:13
Date and time: 2024-06-05 13:45:44
Date and time: 2024-06-05 13:54:52
Completion time: 2024-06-05T13:54:52.1654988-07:00

vs

Native SQL
This took about 45 seconds.

@griffitmatt
Copy link

Hi Steve, the OLA (Online Archival) script execution time will vary based on the table size and system resources. This is because it assesses the fragmentation level to determine the appropriate maintenance action, such as an index reorganization or an index rebuild.

@stevetrinhwork
Copy link
Author

Hmmm, so I should pass complete set of tables/indexes to process so it only has to do it once?

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