microsoft / tigertoolbox

Toolbox repository for Tiger team
http://aka.ms/sqlserverteam
Other
1.48k stars 740 forks source link

Why doesn´t you permit to execute the rebuild on online mode on SQL Azure? #238

Open japineda3 opened 3 years ago

japineda3 commented 3 years ago

Hi, Why doesn´t you include the version of SQL Azure in this check?

### /* Refer to http://docs.microsoft.com/sql/t-sql/functions/serverproperty-transact-sql */ IF (SELECT SERVERPROPERTY('EditionID')) IN (1804890536, 1872460670, 610778273, -2117995310) SET @editionCheck = 1 -- supports enterprise only features: online rebuilds, partitioned indexes and MaxDOP ELSE SET @editionCheck = 0; -- does not support enterprise only features: online rebuilds, partitioned indexes and MaxDOP

 The version of SQL Azure is 1674378470. You can execute online rebuild on SQL Azure. 

 Then, when you execute the adaptativeindexdefrag which @onlineRebuild = 1 , as in the code you checks is:

_Indexes will be defragmented' + CASE WHEN @onlineRebuild = 0 OR @editionCheck = 0 THEN ' OFFLINE;' ELSE ' ONLINE;' END + ' /* Set online rebuild options; requires Enterprise Edition; not compatible with partition operations, Columnstore indexes in table and XML or Spatial indexes. Up to SQL Server 2008R2, not compatible with clustered indexes with LOB columns in table or non-clustered indexes with LOBs in INCLUDED columns. In SQL Server 2012, not compatible with clustered indexes with LOB columns in table.*/ IF @sqlmajorver <= 11 AND @onlineRebuild = 1 AND @editionCheck = 1 AND @ixtype IN (1,2) AND @containsLOB = 0 AND (@dealMaxPartition IS NULL OR (@dealMaxPartition IS NOT NULL AND @partitionCount = 1)) SET @rebuildcommand = @rebuildcommand + N'ONLINE = ON, ';

cpotemski commented 3 years ago

Had the same problem. Added my SELECT SERVERPROPERTY('EditionID') ID to the IN-List

gbtb commented 1 year ago

I also have a similar problem with REBUILD/REORGANIZE operations on a partition level. They are supported on Standard Edition of Sql Server, but @editionCheck forbids its usage. I think these feature checks should be more granular, binary separation Enterprise/Non-Enterprise is not working well enough.