Backup compression (SQL Server) - SQL Server (2024)

  • Article

Applies to: Backup compression (SQL Server) - SQL Server (1) SQL Server

This article describes the compression of SQL Server backups, including restrictions, performance trade-off of compressing backups, the configuration of backup compression, and the compression ratio. Backup compression is supported on SQL Server editions: Enterprise, Standard, and Developer. Every edition of SQL Server 2008 (10.0.x) and later can restore a compressed backup.

Benefits

  • Because a compressed backup is smaller than an uncompressed backup of the same data, compressing a backup typically requires less device I/O and therefore usually increases backup speed significantly.

    For more information, see Performance Impact of Compressing Backups, later in this article.

Restrictions

The following restrictions apply to compressed backups:

Performance impact of compressing backups

By default, compression significantly increases CPU usage, and the additional CPU consumed by the compression process might adversely impact concurrent operations. Therefore, you might want to create low-priority compressed backups in a session whose CPU usage is limited by Resource Governor. For more information, see Use Resource Governor to Limit CPU Usage by Backup Compression (Transact-SQL).

Beginning with SQL Server 2022 (16.x), you can use to compress backups and offload the CPU resources for the backup.

To obtain a good picture of your backup I/O performance, you can isolate the backup I/O to or from devices by evaluating the following sorts of performance counters:

  • Windows I/O performance counters, such as the physical-disk counters

  • The Device Throughput Bytes/sec counter of the SQLServer:Backup Device object

  • The Backup/Restore Throughput/sec counter of the SQLServer:Databases object

For information about Windows counters, see Windows help. For information about how to work with SQL Server counters, see Use SQL Server Objects.

Calculate the compression ratio of a compressed backup

To calculate the compression ratio of a backup, use the values for the backup in the backup_size and compressed_backup_size columns of the backupset history table, as follows:

backup_size:compressed_backup_size

For example, a 3:1 compression ratio indicates that you are saving about 66% on disk space. To query on these columns, you can use the following Transact-SQL statement:

SELECT backup_size/compressed_backup_size FROM msdb..backupset; 

The compression ratio of a compressed backup depends on the data that has been compressed. A variety of factors can impact the compression ratio obtained. Major factors include:

  • The type of data.

    Character data compresses more than other types of data.

  • The consistency of the data among rows on a page.

    Typically, if a page contains several rows in which a field contains the same value, significant compression might occur for that value. In contrast, for a database that contains random data or that contains only one large row per page, a compressed backup would be almost as large as an uncompressed backup.

  • Whether the data is encrypted

    Encrypted data compresses significantly less than equivalent unencrypted data. For example, if data is encrypted at the column level with Always Encrypted, or with other application-level encryption, compressing backups might not reduce the size significantly.

    For more information related to compressing databases encrypted with Transparent Data Encryption (TDE), see Backup compression with TDE.

  • Whether the database is compressed.

    If the database is compressed, compressing backups might not reduce their size by much, if at all.

Backup compression with TDE

Starting with SQL Server 2016 (13.x), setting MAXTRANSFERSIZE larger than 65536 (64 KB) enables an optimized compression algorithm for Transparent Data Encryption (TDE) encrypted databases that first decrypts a page, compresses it, and then encrypts it again. If MAXTRANSFERSIZE is not specified, or if MAXTRANSFERSIZE = 65536 (64 KB) is used, backup compression with TDE encrypted databases directly compresses the encrypted pages, and may not yield good compression ratios. For more information, see Backup Compression for TDE-enabled Databases.

Starting with SQL Server 2019 (15.x) CU5, setting MAXTRANSFERSIZE is no longer required to enable this optimized compression algorithm with TDE. If the backup command is specified WITH COMPRESSION or the backup compression default server configuration is set to 1, MAXTRANSFERSIZE will automatically be increased to 128K to enable the optimized algorithm. If MAXTRANSFERSIZE is specified on the backup command with a value > 64K, the provided value will be honored. In other words, SQL Server will never automatically decrease the value, it will only increase it. If you need to back up a TDE encrypted database with MAXTRANSFERSIZE = 65536, you must specify WITH NO_COMPRESSION or ensure that the backup compression default server configuration is set to 0.

For more information, see BACKUP (Transact-SQL).

Allocation of space for the backup file

For compressed backups, the size of the final backup file depends on how compressible the data is, and this is unknown before the backup operation finishes. Therefore, by default, when backing up a database using compression, the Database Engine uses a pre-allocation algorithm for the backup file. This algorithm pre-allocates a predefined percentage of the size of the database for the backup file. If more space is needed during the backup operation, the Database Engine grows the file. If the final size is less than the allocated space, at the end of the backup operation, the Database Engine shrinks the file to the actual final size of the backup.

To allow the backup file to grow only as needed to reach its final size, use trace flag 3042. Trace flag 3042 causes the backup operation to bypass the default backup compression pre-allocation algorithm. This trace flag is useful if you need to save on space by allocating only the actual size required for the compressed backup. However, using this trace flag might cause a slight performance penalty (a possible increase in the duration of the backup operation).

  • Configure Backup Compression (SQL Server)

  • View or Configure the backup compression default Server Configuration Option

  • Use Resource Governor to Limit CPU Usage by Backup Compression (Transact-SQL)

  • DBCC TRACEON (Transact-SQL)

  • DBCC TRACEOFF (Transact-SQL)

Next steps

Backup Overview (SQL Server)
Trace Flags (Transact-SQL)

Backup compression (SQL Server) - SQL Server (2024)
Top Articles
Get Your Computer Screen Back to Normal Size | Geeks on Site
Four Big Retirement Risks to Consider and Prepare For
Alan Miller Jewelers Oregon Ohio
Ofw Pinoy Channel Su
Get train & bus departures - Android
Wmu Course Offerings
Nc Maxpreps
Routing Number 041203824
Words From Cactusi
Gw2 Legendary Amulet
How to Watch Braves vs. Dodgers: TV Channel & Live Stream - September 15
Violent Night Showtimes Near Amc Fashion Valley 18
The Many Faces of the Craigslist Killer
How to watch free movies online
Drago Funeral Home & Cremation Services Obituaries
Seattle Rpz
Busted Barren County Ky
Interactive Maps: States where guns are sold online most
Dallas Cowboys On Sirius Xm Radio
Soccer Zone Discount Code
Nhl Tankathon Mock Draft
bode - Bode frequency response of dynamic system
Why Does Lawrence Jones Have Ptsd
Roane County Arrests Today
Drying Cloths At A Hammam Crossword Clue
Kabob-House-Spokane Photos
Inter Miami Vs Fc Dallas Total Sportek
Craigslist Ludington Michigan
Cable Cove Whale Watching
Cosas Aesthetic Para Decorar Tu Cuarto Para Imprimir
Craigslist Sf Garage Sales
Stubhub Elton John Dodger Stadium
Robert A McDougal: XPP Tutorial
Gridwords Factoring 1 Answers Pdf
Acuity Eye Group - La Quinta Photos
Calculator Souo
Newcardapply Com 21961
1400 Kg To Lb
Facebook Marketplace Marrero La
The Boogeyman Showtimes Near Surf Cinemas
Today's Gas Price At Buc-Ee's
Culver's of Whitewater, WI - W Main St
Easy Pigs in a Blanket Recipe - Emmandi's Kitchen
Wilson Tattoo Shops
Mathews Vertix Mod Chart
6576771660
Cleveland Save 25% - Lighthouse Immersive Studios | Buy Tickets
Lebron James Name Soundalikes
How to Find Mugshots: 11 Steps (with Pictures) - wikiHow
Kushfly Promo Code
Food and Water Safety During Power Outages and Floods
Urban Airship Acquires Accengage, Extending Its Worldwide Leadership With Unmatched Presence Across Europe
Latest Posts
Article information

Author: Barbera Armstrong

Last Updated:

Views: 5595

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.