SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Used Pages vs Data Pages


Used Pages vs Data Pages

Author
Message
PiMané
PiMané
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1036 Visits: 1334
Hi,

I executed the following code to determine the size that a certain table takes no the database:

select
o.name AS Table_Name,
i.index_id, i.type as i_type, p.rows,
a.total_pages, a.used_pages, a.data_pages, a.type alloc_type
from sys.objects o
inner join sys.indexes i on o.object_id = i.object_id
inner join sys.partitions as p on i.object_id = p.object_id and i.index_id = p.index_id
inner join sys.allocation_units as a on p.partition_id = a.container_id
where o.is_ms_shipped = 0 and o.name= 'AlertasUtilizadorLog'
order by o.name, i.type

exec sp_spaceused 'AlertasUtilizadorLog'


I also executed the sp_spaceused to compare both results.
The output was:

Table_Name index_id i_type rows total_pages used_pages data_pages alloc_type
AlertasUtilizadorLog 0 0 319 57 54 53 1
AlertasUtilizadorLog 0 0 319 209 208 0 2
AlertasUtilizadorLog 2 2 319 4 4 2 1

name rows reserved data index_size unused
AlertasUtilizadorLog 319 2160 KB 2088 KB 40 KB 32 KB



the reserved size is the sum of total_pages.
the data size is the sum of data_pages for alloc_type = 1 and used_pages for alloc_type = 2 and index_type <= 1 (CLUSTERED OR HEAP).
the unused size is the sum of total_pages less the sum of used_pages.
now comes my "problem"... the sum of used_pages for indexes (i_type > 1) is 4 and sp_spaceused says 5...
How is that?! I can get that value, just subtract used_pages to total_pages and I get that value but why hasn't the sum of all indexes have that value?!
Just one more... total_pages or reserved is the size the data occupies on disk... but used_pages isn't suppose to be the data space or does it have "trash" and the real data is data_pages?

Thanks,
Pedro



If you need to work better, try working less...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search