SQL 2008開啟頁面壓縮後如何回收空間? (How to reclaim space after turning on page compression in SQL 2008?)


問題描述

SQL 2008開啟頁面壓縮後如何回收空間? (How to reclaim space after turning on page compression in SQL 2008?)

I have just turned on page compression on a table (SQL 2008 Ent) using the following command:

ALTER TABLE [dbo].[Table1] REBUILD PARTITION = ALL
WITH 
(DATA_COMPRESSION = PAGE
)

The hard drive now contains 50GB less space than before. I'm guessing that I need to run a command to reclaim the space. Anyone know it?

‑‑‑‑‑

參考解法

方法 1:

Have you checked using the table size using sp_spaceused?

Disk space used does not equal space used by data. The compression will have affected log file size (all has to be logged) and required some free working space (like the rule of thumb that index rebuild requires free space = 1.2 times largest table space).

Another option is that you need to rebuild the clustered index because it's fragmented. This compacts data and is the only way to reclaim space for text columns.

Also, read Linchi Shea's articles on data compression

方法 2:

I feel embarrassed even asking this question, but is it something that could be fixed by shrink the database in question? As it compressed the pages, perhaps it left the space free all throughout the file, and the data files just need to be condensed and shrunk to reclaim the space...

If it created a new, compressed copy of the table and then removed the old one from the file, but didn't shrink the file internally, this might also explain your sudden lack of space on the drive as well.

If this is the case, then a simple "DBCC SHRINKDATABASE('my_database')" should do the trick. NOTE: This may take a long time, and lock the database during that time so as to prevent access, so schedule it wisely.

(by Mr. FlibblegbnSqlRyan)

參考文件

  1. How to reclaim space after turning on page compression in SQL 2008? (CC BY‑SA 3.0/4.0)

#compression #sql-server-2008






相關問題

CSS 壓縮和組合 / js 縮小 - 在運行時或構建時更好? (CSS compression & combining / js minification - Better to do at runtime or at build time?)

在javascript中壓縮包含音頻PCM數據的blob (compress blob containing audio PCM data in javascript)

如何提高@font-face 的加載性能 (How to improve loading performance of @font-face)

ServiceStack 流壓縮 (ServiceStack Stream Compression)

有沒有辦法讀取壓縮存檔的屬性? (Is there any way to read the properties of a Compressed Archive?)

德爾福 2009 中的 Zlib (Zlib in Delphi 2009)

SQL 2008開啟頁面壓縮後如何回收空間? (How to reclaim space after turning on page compression in SQL 2008?)

本機 Lua 中的高效可變字節數組 (Efficient mutable byte array in native Lua)

在 JavaScript 中壓縮純文本? (Compressing plaintext in JavaScript?)

如何遞歸壓縮文件夾? (How to zip a folder recursively?)

使用 GZIPOutputStream 壓縮字符串 (Compressing a string using GZIPOutputStream)

壓縮後 1 KB 可以容納多少文本? (How much text I can fit in 1 kilobyte with compression?)







留言討論