At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.
-- Check fragmentation on db(sample) Declare @dbid INT Set @dbid =DB_ID('sample') select dbschemas.[name] as 'Schema', dbtables.[name] as 'Table', dbindexes.[name] as 'Index', indexstats.avg_fragmentation_in_percent, indexstats.page_count from sys.dm_db_index_physical_stats (@dbid, NULL, NULL, NULL, NULL) as indexstats INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id] INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id] INNER JOIN sys.indexes as dbindexes on dbindexes.[object_id] = indexstats.[object_id] AND indexstats.index_id = dbindexes.index_id where indexstats.database_id = @dbid order by indexstats.avg_fragmentation_in_percent desc
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.