Estimates the amount of space required for a table and its indexes, and the time needed to create the index.
sp_estspace table_name, no_of_rows, fill_factor, cols_to_max, textbin_len, iosec, page_size
sp_estspace titles, 10000, 50, "title,notes", 0, 25
name type idx_level Pages Kbytes ---------------- ------------ --------- ------------ ------------ titles data 0 3364 6728 titles text/image 0 0 0 titleidind clustered 0 21 43 titleidind clustered 1 1 2 titleind nonclustered 0 1001 2002 titleind nonclustered 1 54 107 titleind nonclustered 2 4 8 titleind nonclustered 3 1 2 Total_Mbytes ----------------- 8.68 name type total_pages time_mins ------------------ ------------ ------------ ------------ titleidind clustered 3386 13 titleind nonclustered 1060 5 titles data 0 2
declare @i int select @i = avg(datalength(pic)) from au_pix exec sp_estspace au_pix, 1000, null, null, 16, @i
au_pix has no indexes name type idx_level Pages Kbytes --------------- ------------ --------- --------- --------- au_pix data 0 31 63 au_pix text/image 0 21000 42000 Total_Mbytes ----------------- 41.08
sp_estspace titles, 50000
name type idx_level Pages Kbytes --------------- ------------ --------- ------------ ------------ titles data 0 4912 9824 titleidind clustered 0 31 61 titleidind clustered 1 1 2 titleind nonclustered 0 1390 2780 titleind nonclustered 1 42 84 titleind nonclustered 2 2 4 titleind nonclustered 3 1 2 Total_Mbytes ----------------- 12.46 name type total_pages time_mins ------------------ ------------ ------------ ------------ titleidind clustered 4943 19 titleind nonclustered 1435 8
declare @i int select @i = avg(datalength(copy)) from blurbs exec sp_estspace blurbs, 6, null, null, 16, @i, "16k"
name type idx_level Pages Kbytes ------------------------ ----------- --------- --------- ------ blurbs data 0 8 128 blurbs text/image 0 6 96 blurbs_ind clustered 0 1 16 blurbs_ind clustered 1 1 16 Total_Mbytes ----------------- 0.25 name type total_pages time_mins ------------------------ ------------ ------------ ------------ blurbs_ind clustered 10 0 blurbs data 6 0
This example is run on a 2K server, and indicates that the blurbs table would require .25MB after it is migrated to a 16K server. Below is the same query run on a 16K server, which verifies the .25MB space requirement:
declare @i int select @i = avg(datalength(copy)) from blurbs exec sp_estspace blurbs, 6, null, null, 16, @i, "16k"
name type idx_level Pages Kbytes ------------------------ ------------ --------- --------- ------ blurbs data 0 8 128 blurbs text/image 0 6 96 blurbs_ind clustered 0 1 16 blurbs_ind clustered 1 1 16 Total_Mbytes ----------------- 0.25 name type total_pages time_mins ----------------------- ------------ ------------ ---------- blurbs_ind clustered 10 0 blurbs data 6 0
declare @i int select @i = avg(datalength(copy)) from blurbs exec sp_estspace blurbs, 1000, null, null, 16, @i, "2k"
name type idx_level Pages Kbytes ----------------------- ------------ --------- ------------ ------ blurbs data 0 16 32 blurbs text/image 0 1000 2000 blurbs_ind clustered 0 1 2 blurbs_ind clustered 1 1 2 Total_Mbytes ------------ 1.99 name type total_pages time_mins ----------------------- ------------ ------------ --------- blurbs_ind clustered 18 0 blurbs data 1000 0
Create the table.
Create all indexes on the table.
Run sp_estspace, giving the table name, the estimated number of rows for the table, and the optional arguments, as needed.
For information about tables or columns, use sp_help tablename.
See also create index, create table in Reference Manual: Commands.
You do not need to insert data into the tables. sp_estspace uses information in the system tables—not the size of the data in the tables—to calculate the size of tables and indexes.
Any user can execute sp_estspace. Permission checks do not differ based on the granular permissions settings.
Values in event and extrainfo columns from the sysaudits table are:
Information | Values |
---|---|
Event | 38 |
Audit option | exec_procedure |
Command or access audited | Execution of a procedure |
Information in extrainfo |
|