Article ID: 90758 - Last Review: November 14, 2003 - Revision: 3.0 INF: Description of sysindexes and sp_spaceused
This article was previously published under Q90758 SUMMARY
The sysindexes system table records the number of pages allocated and used by each table, index, and text or image column in a database. The sp_spaceused system stored procedure reports this information to users. This article explains some of the data in sysindexes and how it is used by sp_spaceused to calculate the values it reports.
MORE INFORMATION
The sysindexes table will have 1 to 255 rows for each table in the database. All rows for a given table will have the table's object ID in their ID column. All sysindexes rows for a table can be found with the following query:
dpages = Number of data pages, excluding text and image columns. reserved = Number of pages reserved for dpages and ALL indexes. used = Number of pages used for dpages and ALL indexes. rows = Number of rows in the dpages. dpages = Number of data pages, excluding text and image columns. reserved = Number of pages reserved for the dpages and ALL indexes. used = Number of pages used for dpages and ALL indexes. rows = Number of rows in the dpages.
reserved = Number of pages reserved for all text or image data in the
table (all columns).
used = Number of pages used for all text or image data in the table
(all columns).
dpages and rows will be 0.
75191
(http://support.microsoft.com/kb/75191/EN-US/
)
INF: Explanation of Index ID's Found in SYSINDEXES
Note that the data returned by SELECT statements on sysindexes is in numbers of pages. The number of pages is multiplied by the pagesize from
spt_values to get the number of bytes in the pages, then divided by 1,024 to get the number of kilobytes, which is the value returned by
sp_spaceused. The pagesize in spt_values for SQL Server 6.5 and earlier is 2,048, so multiplying the values in the sysindexes columns by two gives the numbers of kilobytes reported by sp_spaceused.
If you run sp_spaceused against a table, as in exec sp_spaceused table_name, it will select only the sysindexes rows that relate to the table by first setting @id = object_id('table_name') and then using (id = @id) in the WHERE clause to restrict the selects to the table named. If you did not enter a table name, then sp_spaceused does not restrict the SELECT statements with id = @id, so each SELECT returns rows for all tables in the database. The SELECT statements given here are in the form that is used if a table name is specified. If sp_spaceused is issued against the entire database, the SELECT statements are the same except that the id = @id clause is not used. The following SELECT statements show how sp_spaceused calculates the number of pages in each space usage category it reports. It then adjusts these numbers using the algorithm above to determine the numbers of kilobytes it reports for each category. For the most thorough update of sysindexes (or if you suspect that the information in sysindexes is incorrect), run DBCC UPDATEUSAGE or use the optional "@updateusage=true" parameter for sp_spaceused. Note that DBCC UPDATEUSAGE may take a long time to run and can consume a significant amount of system resources. Also, the dpages values in sysindexes are not guaranteed to be accurate. For additional information, click the article number below to view the article in the Microsoft Knowledge Base: 183100
(http://support.microsoft.com/kb/183100/EN-US/
)
PRB: Incorrect Log Size Reported in SEM or Performance Monitor
APPLIES TO
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email

Back to the top
