索引 碎片查看
DBCC SHOWCONTIG (ep_ProdCardToRollbase)--ep_ProdCardToRollbase表名
输出:
DBCC SHOWCONTIG scanning 'ep_ProdCardToRollBase' table...
Table: 'ep_ProdCardToRollBase' (581433691); index ID: 1, database ID: 21
TABLE level scan performed.
- Pages Scanned................................: 43
- Extents Scanned..............................: 6
- Extent Switches..............................: 5
- Avg. Pages per Extent........................: 7.2
- Scan Density [Best Count:Actual Count].......: 100.00% [6:6]
- Logical Scan Fragmentation ..................: 0.00%
- Extent Scan Fragmentation ...................: 0.00%
- Avg. Bytes Free per Page.....................: 1533.9
- Avg. Page Density (full).....................: 81.05% 密度越低,说明碎片越多
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
创建非聚集索引: CREATE NONCLUSTERED INDEX [ndx_for_cascaderelationship_ep_ep_card_ep_prodcardtoroll_ProductionOrderCardNo] ON [dbo].[ep_ProdCardToRollBase] ( [ep_ProductionOrderCardNo] ASC ) WHERE ([ep_ProductionOrderCardNo] IS NOT NULL) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY] GO