how to find the size occupied by one row in a tablesunil
Let me say you have a table with three columns
Bookid as integer (4 bytes)
Price as money (8 bytes)
Quantity as bigint (8 bytes)
Total bytes per row=4+8+8= 20 bytes
Now you estimate that your table will have 10000 rows
Number of rows can fit on 8k data page
8060/20=403 rows per page
As I said we have 10000 rows we calculate data pages needed
10000/403=25 data pages
8192*25=204,800 Total bytes needed for the table
204,800/1024=200kb
200/1024=0.1mb
"sunil" <anonymous@.discussions.microsoft.com> wrote in message
news:E76F0F6D-0641-4388-9B2C-D59A596A1EDD@.microsoft.com...
> how to find the size occupied by one row in a table
>
>|||Thanks for the answer, but I want something different i.e, I want to check t
he average space occupied by a table. I've used sp_spaceused but I could not
get the proper result if I create a small tabel say with name char(5) and i
nsert one row even then it
shows data occupied is 16 KB, so can you help me in finding exactly how to f
ind how much data is occupied by a table.
Thanks and Regards
Sunil|||In order to get the correct result ,you will have to run update statistics.
For more details please refer to the BOL.
"Sunil" <anonymous@.discussions.microsoft.com> wrote in message
news:E962D2EF-BFB4-4304-ACEC-578D5E28A50D@.microsoft.com...
> Thanks for the answer, but I want something different i.e, I want to check
the average space occupied by a table. I've used sp_spaceused but I could
not get the proper result if I create a small tabel say with name char(5)
and insert one row even then it shows data occupied is 16 KB, so can you
help me in finding exactly how to find how much data is occupied by a table.
>
> Thanks and Regards
>
> Sunil|||> Thanks for the answer, but I want something different i.e, I want to check
the average space occupied by a table. I've used sp_spaceused but I could
not get the proper result if I create a small tabel say with name char(5)
and insert one row even then it shows data occupied is 16 KB, so can you
help me in finding exactly how to find how much data is occupied by a table.
Exactly 16KB, as sp_spaceused returned. SQL Server allocates 8k pages, you
get one page as soon as you insert first row, and each table has an IAM page
as well. Check the "Physical Database Architecture" chapter in Books OnLine
for details.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment