MS-SQL fast count
SELECT COUNT(*) FROM dbo.<database> can take a long time. If accuracy is not 100% needed this might help:
SELECT SUM(p.rows) FROM sys.partitions AS p
INNER JOIN sys.tables AS t
ON p.[object_id] = t.[object_id]
INNER JOIN sys.schemas AS s
ON s.[schema_id] = t.[schema_id]
WHERE t.name = N'<database>'
AND s.name = N'dbo'
AND p.index_id IN (0,1);