I need to figure out how many files have been inserted on a MS Sql Server FileTable along with their average size.
The FileTable is already quite large, it' housing around 27GBs of data.
This is the SQL i'm using, but it's extremely slow. It's been running for over an hour, and it still hasn't finish. Is there any way to speed up the query?
SELECT round(datalength([file_stream]) / 1048576.0, 2) As FileSizeMB, COUNT(*)
FROM [dbo].[Document] WITH(NOLOCK)
GROUP BY round(datalength([file_stream]) / 1048576.0, 2)
ORDER BY round(datalength([file_stream]) / 1048576.0, 2)
Not sure if this will work, I don't have FileTable implemented, but this will get size of tables.