Querying sys.partitions can return an approximate row count for a table.
I've noticed that this is returning the same row count for all partitions, regardless of the actual content (even for empty partitions).
The table has a clustered columnstore index and statistics have been created on almost all of the columns. Statistics are updated daily after each data load. The table is partitioned by date.
sys.partitions query:
SELECT convert(date, convert(varchar,rv.[value])) as partitionDate, p.rows as syspartitions_RowCount
FROM sys.tables t
join sys.schemas sc on sc.schema_id = t.schema_id
JOIN sys.partitions p ON p.[object_id] = t.[object_id]
JOIN sys.indexes i ON i.[object_id] = p.[object_id]
AND i.[index_id] = p.[index_id]
JOIN sys.data_spaces ds ON ds.[data_space_id] = i.[data_space_id]
LEFT JOIN sys.partition_schemes ps ON ps.[data_space_id] = ds.[data_space_id]
LEFT JOIN sys.partition_functions pf ON pf.[function_id] = ps.[function_id]
LEFT JOIN sys.partition_range_values rv ON rv.[function_id] = pf.[function_id]
AND rv.[boundary_id]+1 = p.[partition_number]
WHERE p.[index_id] <=1
and t.[name] ='tbl'
and sc.name = 'temp'
and convert(date, convert(varchar,rv.[value])) > '2016-05-31'
order by convert(date, convert(varchar,rv.[value])),
t.[name]
table query:
select date, count_big(*) as real_count
from temp.tbl
where date > '2016-05-31'
group by date
order by date
Sample results from both queries:
