Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Introducing SQL Server to OracleMissing foreign key constraints »
    comments

    I got a brand new SQL Server 2008 test server and decided to test backup compression. I picked 2 databases to do this test; the smaller database is 4.8GB in size the bigger database is about 44 GB in size.
    Let's start with the smaller database.
    First I backed the database up, one backup used compression while the other one did not.

    Let's look at some code

    1. BACKUP DATABASE [SmallDB] TO  DISK = N'V:\SmallDB_Compressed.BAK'
    2. WITH NOFORMAT, NOINIT,  
    3. NAME = N'SmallDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, COMPRESSION,  
    4. STATS = 2
    5. GO

    The compressed backup took 34.313 seconds (138.881 MB/sec) to complete.

    1. BACKUP DATABASE [SmallDB] TO  DISK = N'V:\SmallDB_UnCompressed.BAK'
    2. WITH NOFORMAT, NOINIT,  
    3. NAME = N'SmallDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  
    4. STATS = 2
    5. GO

    The uncompressed backup took 41.716 seconds (114.235 MB/sec) to complete.

    As you can see the compressed backup was a little faster. The size of the backup was 1.25 GB for the compressed backup and 4.8 GB for the uncompressed backup

    After I did the backups I decided to do the restores.

    1. RESTORE DATABASE [SmallDB]
    2. FROM  DISK = N'V:\SmallDB_Compressed.BAK'
    3. WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 1
    4. GO

    RESTORE DATABASE successfully processed 609980 pages in 23.524 seconds (202.578 MB/sec).

    1. RESTORE DATABASE [SmallDB]
    2. FROM  DISK = N'V:\SmallDB_UnCompressed.BAK'
    3. WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 1
    4. GO

    RESTORE DATABASE successfully processed 609977 pages in 38.951 seconds (122.344 MB/sec).

    The restores had a bigger difference in time than the backups.

    After I was done with the small database I decided to take a bigger database, this database is 44 GB, I wanted to see if using a bigger database would make a bigger or a smaller difference when using compressed backups compared to uncompressed backups.

    1. BACKUP DATABASE MediumDB TO  DISK = N'V:\MediumDB_Compressed.BAK'
    2. WITH NOFORMAT, NOINIT,  
    3. NAME = N'MediumDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, COMPRESSION,  
    4. STATS = 2
    5. GO

    The compressed backup took 303.113 seconds (142.845 MB/sec) to complete.

    1. BACKUP DATABASE MediumDB TO  DISK = N'V:\MediumDB_UnCompressed.BAK'
    2. WITH NOFORMAT, NOINIT,  
    3. NAME = N'MediumDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  
    4. STATS = 2
    5. GO

    The uncompressed backup took 395.740 seconds (109.410 MB/sec) to complete.

    Just as before with the small database, the compressed backup was a little faster. The size of the backup was 9.725 GB for the compressed backup and 44.338 GB for the uncompressed backup

    Now let's take a look at the restore.

    1. RESTORE DATABASE [MediumDB]
    2. FROM  DISK = N'V:\MediumDB_Compressed.BAK'
    3. WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 1
    4. GO

    RESTORE DATABASE successfully processed 5542183 pages in 215.319 seconds (201.089 MB/sec).

    1. RESTORE DATABASE [MediumDB]
    2. FROM  DISK = N'V:\MediumDB_UnCompressed.BAK'
    3. WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 1
    4. GO

    RESTORE DATABASE successfully processed 5542177 pages in 456.590 seconds (94.829 MB/sec)

    The restore of the compressed backup took less than half the time of the uncompressed backup

    To sum it all up:

    1. Backups are faster if you use compression
    2. Restore are significantly faster if you restore from a compressed backup
    3. Since the files are small you can store a lot more backups on the server and if you have to move it to another server it will be much faster also.

    Another good thing is that with SQL Server 2008 R2 backup compression will be available in the standard edition as well, until now backup compression was only an Enterprise Edition feature

    All in all I was impressed with backup compression and I can't see a reason why you would not want to use it. It does use more CPU to backup when using compression but I am more RAM bound than CPU bound.




    *** If you have a SQL related question try our Microsoft SQL Server Programming forum or our Microsoft SQL Server Admin forum

    About the Author

    User bio imageDenis has been working with SQL Server since version 6.5. Although he worked as an ASP/JSP/ColdFusion developer before the dot com bust, he has been working exclusively as a database developer/architect since 2002. In addition to English, Denis is also fluent in Croatian and Dutch, but he can curse in many other languages and dialects (just ask the SQL optimizer) He lives in Princeton, NJ with his wife and three kids.
    Social SitingsTwitterFacebookLinkedInHomePageFlickrLTD RSS Feed
    2699 views
    Instapaper

    4 comments

    Comment from: Natas [Member] Email
    Natas Interesting...I am glad that it will be in the standard edition in the future...

    Not everyone can afford Enterprise Edition :-(
    11/23/09 @ 11:02
    Comment from: Alex Ullrich [Member] Email
    Alex Ullrich Thanks Denis, never really looked at this before. I have a database that I'm constantly backing up to a USB stick so I can use it on my laptop when I'm not at home. This sped up the backups significantly, and will let me keep almost twice as much history :)
    11/24/09 @ 12:21
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky Here is Stats from Michel Fournier posted on UT:
    1. Downloaded a 4.4 GB ISO file
    2. Clicked on it and Nero started automatically
    3. Burned it into a DVD
    4. Put the DVD in and Setup.exe was run
    5. Clicked on a bunch of screen to confirm and finally Ready to Upgrade
    6. Ran SSMS
    7. SSMS shows SQL Server 2008 R2 at startup
    8. Did some backup tests with the LevelExtreme and UniversalThread databases either at compress mode and non compress mode

    The image 1 attached shows the information for the LevelExtreme database.

    1. LevelExtreme.mdf is 90 MB
    2. The compress backup is 11 MB
    3. The normal backup is 84 MB
    4. If I zip the compress backup, it doesn't save that much
    5. If I zip the non compres backup, we end up with a small file
    6. The ratio is almost 8 times smaller

    The image 2 attached shows the information for the UniversalThread database.

    1. UniversalThread.mdf is 9.4GMB
    2. The compressed backup is 2.8 MB
    3. The normal backup is 84 MB
    4. If I zip the compress backup, it doesn't save that much
    5. If I zip the non compress backup, we end up with a small file
    6. The ratio is almost 3.5 times smaller
    7. Using Winzip to zip the compress backup takes about 1 to 2 minutes
    8. Using Winzip to zip the non compress backup takes about 20 to 30 minutes
    9. The time to do a compress backup took 4.5 minutes

    So, in overall, to obtain the smaller file as possible for the transfer, the previous method is still a winner. However, using the compress method will make it less intensive on the CPU as usually there would be a big process to backup and another one to Zip. For some kind of reason, Winzip detects the compress version and can process the zip file extremely fast.

    So, in overall, if we are looking for a backup file, then the compress mode will make the backup file much smaller. But, if we target to use a backup file for transfer, then the non compress backup with WinZip will make the file a little bit smaller.

    Despite the fact that the compress backup will make it a little bit longer on the FTP transfer time, it saves a lot on the CPU. Before, doing the regular backup, zipping the file and transferring it to a backup server (direct network disk transfer) was taking about an hour. Now, when using the compress backup, because Winzip recognizes that it is already compressd, the CPU time to achieve the same three steps would be about 40 minutes. But, the direct network disk transfer will be a little bit longer because we end up with a 2.8 GB file instead of 2.1.

    Now, just to save about 25 to 28 minutes of CPU, I really do not know if it worths it to use the compress backup. That would have been the way to go if no FTP transfer would be a factor. But, because I have to consider the FTP transfer time, an additional 657 MB makes a big difference.

    For those who wish to obtain a backup file on the server, then, I wouldn't even bother of using WinZip. Because, the difference between the WinZip version of the compress backup and the compress backup itself isn't worth mentioning it. So, basically, using the compress backup is good enough for archive purposes.

    Maybe someone can add more information to this as to know if there would be a way of using the compress mode and obtain a smaller or even about the same file size as scenario #1, which is to do a non compress backup and zip it.

    The tests were done on my Windows 7 Ultimate N 64 bits. It uses SQL Server 2008 R2 64 bits and Winzip 2006. I assume the Winzip 2006 is 32 bits. The PC has 8 GB of RAM. I expect the numbers to be about the same on the server.
    07/25/10 @ 11:42
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky Pictures
    http://www.universalthread.com/Thread%20photos/2010/01473769.jpg

    http://www.universalthread.com/Thread%20photos/2010/01473769-2.jpg
    07/25/10 @ 11:53

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)