Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a data sizer tool available for SQL Server 2005?

I have to estimate the data size of database when populated with forecast values for each table. It should at least include size to be used for data and indexes.

There used to be tool like this in SQL Server 2000 that produced an estimated size when supplied with the amount of records per table (I think it shipped with the SQL 2000 resource kit). I can neither find this tool for 2000 or 2005 :(

I know about sp_spacedused but that is not going to work for me as I have to pre-populate the database with values and I have potentially many scenarios to calculate.

like image 431
Philip Fourie Avatar asked Feb 13 '09 08:02

Philip Fourie


2 Answers

In your shoes, I'd probably just create the database and try to fill it with a representative sample of data and then check what the table sizes look like.

This SQL script does it over all tables - you don't have to call sp_spaceused on each and every single table:

SELECT 
    t.NAME AS TableName,
    i.name as indexName,
    sum(a.total_pages) as TotalPages, 
    sum(a.used_pages) as UsedPages, 
    sum(a.data_pages) as DataPages,
    (sum(a.total_pages) * 8) / 1024 as TotalSpaceMB, 
    (sum(a.used_pages) * 8) / 1024 as UsedSpaceMB, 
    (sum(a.data_pages) * 8) / 1024 as DataSpaceMB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
WHERE 
    t.NAME NOT LIKE 'dt%' AND
    i.OBJECT_ID > 255 AND   
    i.index_id <= 1
GROUP BY 
    t.NAME, i.object_id, i.index_id, i.name 
ORDER BY 
    object_name(i.object_id) 
like image 74
marc_s Avatar answered Oct 11 '22 07:10

marc_s


Last time I did this it was excel, pencil, back of envelope and educated guess work. The answer wasn't too inaccurate. I guess you're talking serious data volumes as disk is so cheap/available these days that all but the biggest DBs will run on small(ish) servers.

Can you give more details of expected row counts and the kind of data you'll be storing. BTW don't go with Blobs/images/video in the DB - it's an ugly thing once it scales.

like image 30
MrTelly Avatar answered Oct 11 '22 09:10

MrTelly