Defragmentierung von Indexen

SELECT 

–DB_ID(‘Live_Staging’)

DB_NAME(database_id)

,*

–SELECT stats.index_id as id, name, avg_fragmentation_in_percent

FROM sys.dm_db_index_physical_stats (DB_ID(N’Live_DWH

‘), NULL, NULL, NULL, NULL) AS stats

    JOIN sys.indexes AS indx ON stats.object_id = indx.object_id

      AND stats.index_id = indx.index_id AND name IS NOT NULL

where database_id =6

  –where name = ‘idx_customerCredit_customer_endamount’

 

  –where name = ‘orderItemsAddresses_addressType_inkl_orderItemId_addressId’

  order by avg_fragmentation_in_percent desc

1 Kommentar
  1. AZConAdmin sagte:

    SELECT

    ‘ALTER INDEX ALL ON ‘ + TABLE_NAME + ‘ REORGANIZE;

    GO’

    FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ‘BASE TABLE’ AND TABLE_CATALOG = ‘Live_Staging’

Hinterlasse einen Kommentar

An der Diskussion beteiligen?
Hinterlasse uns deinen Kommentar!

Schreibe einen Kommentar