根据列对表进行分区以提高性能,对于特定分区,sys.partition表中的行计数为1。但是实际的表格保存数据请查看屏幕截图。
SELECT OBJECT_NAME(i.OBJECT_ID) AS TableName,
i.name AS IndexName,
indexstats.avg_fragmentation_in_percent ,
indexstats.partition_number,
fg.name AS FileGroupName,
value,
fragment_count,
page_count
from sys.dm_db_index_physical_stats(@db_id, @object_id, NULL, NULL , 'DETAILED') indexstats
INNER JOIN sys.indexes i ON i.OBJECT_ID = indexstats.OBJECT_ID
AND i.index_id = indexstats.index_id
JOIN sys.partition_schemes ps
ON (ps.data_space_id = i.data_space_id)
JOIN sys.partition_functions f
ON (f.function_id = ps.function_id)
LEFT JOIN sys.partition_range_values rv
ON (f.function_id = rv.function_id
AND indexstats.partition_number = rv.boundary_id)
JOIN sys.destination_data_spaces dds
ON (dds.partition_scheme_id = ps.data_space_id
AND dds.destination_id = indexstats.partition_number)
JOIN sys.filegroups fg
ON (dds.data_space_id = fg.data_space_id)
WHERE indexstats.avg_fragmentation_in_percent > 20
select count(1) from table where id = 50002
是否可以通过不更新sys.partitions中的行数来获取表中的数据? 我已确保索引未处于禁用模式。