0

The documentation is very clear on this point

Compression doesn't affect backup and restore.

but how is that possible? Surely, if my table is smaller (due to compression), then that should have some impact on backups/restores? If my table is smaller, then it should load faster. If my table needs some decompressing, then that should make it takes longer. Either way, I just can't believe that data compression does absolutely nothing to backups and restores.

What am I missing?

asked Apr 15, 2024 at 19:25
5
  • The Linked Article indicates that data will be uncompressed for other SQL Server Components, so to backup the data, SQL Server will decompress it first Commented Apr 15, 2024 at 20:18
  • 3
    I think that the author means that compression is transparent to backup and restore. There is no compression and decompression going on when you backup or restore. Commented Apr 15, 2024 at 20:49
  • @TiborKaraszi That contradicts what the previous comment says. Commented Apr 15, 2024 at 20:51
  • @TiborKaraszi i tend to agree with you but was just pointing out first sentence in the article implies that other part of SQL server will get the data uncompressed, maybe that extended to backups. i may have just misinterpreted the article Commented Apr 16, 2024 at 13:32
  • 1
    @BobKlimes That article has IMO room for improvements regarding how it phrases that part. :-) Backup just shuffles the pages as they are, to disk (as per Charlieface's reply). Commented Apr 17, 2024 at 6:35

1 Answer 1

3

Backup/Restore works on whole pages of the data files.

The rows and pages are compressed and decompressed within the Storage Engine, which is the component that actually reads the column values. The Backup/Restore has no knowledge of what is actually in the pages, it just treats it as a single blob of data.

So it means that there is no compression or decompression happening when you backup or restore.

answered Apr 16, 2024 at 11:21
3
  • So, given that my compression ought to reduce the number of pages, I should hope that data compression reduces the time taken to backup/restore? Commented Apr 16, 2024 at 16:57
  • Yes. It will reduce the IO on backup/restore. Commented Apr 16, 2024 at 19:14
  • One could investigate how backup compression plays into this. Perhaps there could be some bit-patterns for which data compression causes backup compression to be less effective compared to if we didn't have data compression? I.e., we would save on reading from the database files, but lose when writing to the backup file. Probably not worth investigate except from a theoretical standpoint, though. Commented Apr 17, 2024 at 6:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.