Sql-Server

Ola Hallengren 索引腳本未重新索引

  • March 4, 2016

首先,我意識到有人問了一個類似的問題,海報的頁數設置為 1000,索引為 679 頁;不是發生了什麼。

我將 Ola 的腳本設置為

@Databases nvarchar(max)
,@FragmentationLow nvarchar(max) = null
,@FragmentationMedium nvarchar(max) = 'INDEX_REORGANIZE'
,@FragmentationHigh nvarchar(max) = 'INDEX_REBUILD_ONLINE'
,@FragmentationLevel1 int = 50
,@FragmentationLevel2 int = 75
,@PageCountLevel int = 400
,SortInTempdb nvarchar(max) = 'N'
,maxdop int = null
,fillfactor int = null
,PadIndex nvarchar(max) = null
,LOBCompaction nvarchar(max) = 'Y'
,UpdateStatistics nvarchar(max) = 'ALL'
,OnlyModifiedStatistics nvarchar(max) = 'Y'
,StatisticsSample int = null
,StatisticsResample nvarchar(max) = 'N'
,PartitionLevel nvarchar(max) = 'Y'
,MSShippedObjects nvarchar(max) = 'N'
,Indexes nvarchar(max) = 'MyDatabase.dbo.Table'
,TimeLimit int = null
,delay int = null
,WaitAtLowPriorityMaxDuration int = null
,WaitAtLowPriorityAbortAfterWait nvarchar(max) = null
,LockTimeout int = null
,LogToTable nvarchar(max) = 'Y'
,

execute nvarchar(max) = 'Y'

有問題的索引如下:

Page Fullness: 75.77%
Fragmentation: 99.14%
Avg. Row Size: 33
Depth: 4
Index Type: Nonclustered
Leaf-lvl rows: 11130800
Max Size: 33
Min Size: 33
Pages: 63585
Partition ID: 1

它設置得如此之低,因為 1000 大關沒有達到該指數。奇怪的是統計數據正在更新,但索引沒有被重組或重建。

我正在尋找要探索的東西或要思考的概念,這將幫助我解決這個問題。

再一次,如果這個問題已經被問及回答,請原諒我,如果答案如此簡單和愚蠢以至於它盯著我的臉,請原諒我。

謝謝。

表架構

CREATE TABLE [dbo].[Table](
   [column1] [uniqueidentifier] NOT NULL,
   [column2] [uniqueidentifier] NOT NULL,
   [column3] [uniqueidentifier] NOT NULL,
   [column4] [uniqueidentifier] NOT NULL,
   [column5] [nvarchar](50) NULL,
   [column6] [nvarchar](128) NULL,
   [Column7] [money] NOT NULL,
   [column8] [money] NOT NULL,
   [column9] [nvarchar](128) NULL,
   [column10] [nvarchar](64) NULL,
   [column11] [image] NULL,
CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED 
(
   [Column1_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE NONCLUSTERED INDEX [IX_Index] ON [dbo].[Table] 
(
   [column2] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = ON, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 70) ON [PRIMARY]
GO

啊! 是圖片欄。

[column11] [image] NULL,

Online 僅適用於沒有 blob 的表。

執行線上索引操作的指南

引用自:https://dba.stackexchange.com/questions/110814