Count the number of table rows in a user table, average row length, and total number of pages

Source: Internet
Author: User
-- If 0 is specified, the current database is used. The statistics are updated before use.
DBCC updateusage (0)
-- Or
DBCC updateusage ('db ')
-- DBCC updateusage correct the rows, used, reserved, and dpages columns of the sysindexes table and the clustered index.
-- Do not maintain the size of non-clustered Indexes

-- DBCC updateusage will correct the Count of rows, used pages, reserved pages, leaf-level pages, and data pages for each partition in the table or index.

 

Select object_name (ID), dpages used data page, used all index and table data page count,
Total number of pages of all indexes and table data in reserved from sysindexes

Code -- Count the number of table rows in the User table, average row length, and total number of pages
Select name table name, max ([rows]) rows, max (dpages) total data pages,
Max (dpages) * 8000/MAX ([rows]) Average number of bytes of rows from (
Select object_name (ID) Name, rows, dpages
From sysindexes) TT
Where name not like 'sys %'
And rows> 0
And dpages> 50
Group by name
Order by 4 DESC

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.