SQL Server Performance Tuning table compression for SQL Server 2008

Source: Internet
Author: User


When the database is larger, and we want to make a backup, we can start the compression of the database backup, thus reducing the consumption of disk space.


In fact, not only can be compressed at the time of backup, in SQL Server 2008, we can also compress the table, the following compression and compression before the comparison, to demonstrate the SQL Server 2008 powerful table compression capabilities.


Here in the test database to find a larger table, a total of 9,439,661 records,

1, the size of the pre-compression table

sp_spaceused ' TB_WCB '/*name            rows    reserveddata   index_sizeunusedtb_wcb            9439661 746016    KB412216 KB329944 KB3856 kb*/


2. Compact Table size

The row-level compression is enabled here

ALTER TABLE Tb_wcbrebuildwith (data_compression =row)


3. The size of the table after compression

sp_spaceused ' TB_WCB '/*name            rows    reserveddata   index_sizeunusedtb_wcb            9439661 497784    KB167168 KB328120 KB2496 kb*/

4, the comparison after the table compression

As can be seen from 1, the data size before compression is 412M, and after compression is 167M, the size of the table after compression is only 40% of the original table, the effect is obvious, and because most of the table's fields are only IDs, the relative repetition value is not too much.

However, we see that the size of the index varies substantially, so we continue to compress the index:


5. Compression index

Alter index idx_tb_wcb_id on Tb_wcbrebuildwith (Data_compression=row)

6, the comparison after the index compression

sp_spaceused ' ms_visit_qst_opt '/*name            rows    reserveddata    INDEX_SIZEUNUSEDTB_WCB            9439661    317208 KB167168 KB149872 KB168 kb*/

We found that the size of the index before compression is 329M, and after compression is 149M, compression ratio of 45%, the effect is also obvious.


With the compression of tables and indexes, we can reduce the disk space consumed by the table, and allow more data pages to be cached in memory, significantly improving IO efficiency.

SQL Server Performance Tuning table compression for SQL Server 2008

Related Article

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.