Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1730: Fix Compression Failures

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server Error 1730 occurs when the database engine fails to create or alter a table with data compression because the required resources—typically memory or disk space—are unavailable, or there is a conflict with the existing index structure. To resolve this, you must ensure the server has sufficient memory to perform the compression operation and that the transaction log has enough space to handle the rebuild process. The most immediate fix is usually increasing the available memory for the SQL Server instance or performing the compression in smaller batches if the table is exceptionally large.

What You'll Need

  • Administrative access to the SQL Server instance (sysadmin role).
  • SQL Server Management Studio (SSMS) or a compatible T-SQL editor.
  • Access to the server's disk management to verify free space on the drive hosting the transaction log and tempdb.
  • Knowledge of the current memory configuration of the SQL Server instance.

Step-by-Step

  1. Analyze the Error Context: Before attempting a fix, identify exactly when the error occurs. If it happens during a CREATE TABLE statement, the issue is likely related to the initial allocation of compressed pages. If it occurs during an ALTER TABLE... REBUILD, the issue is likely related to the temporary space required to move data from an uncompressed state to a compressed state.
  2. Check Memory Availability: Data compression is a CPU and memory-intensive operation. Check the SQL Server Error Log for "Out of Memory" messages. If the server is under heavy load, the compression process may fail because it cannot allocate a contiguous block of memory for the compression buffer. Try reducing the load on the server or increasing the "Max Server Memory" setting in the Server Properties.
  3. Verify Transaction Log Space: When you alter a table to enable compression, SQL Server essentially rebuilds the table. This generates a significant amount of transaction log data. Ensure that the disk drive containing your .ldf file has enough free space to accommodate the entire size of the table being compressed. If the log file is set to a fixed size, increase the maximum growth limit or manually expand the file.
  4. Evaluate TempDB Capacity: The compression process often uses tempdb to sort and organize data before writing it back to the data file. If tempdb is constrained by a small disk or a strict size limit, Error 1730 can be triggered. Expand tempdb or move it to a drive with more available overhead.
  5. Execute Compression via T-SQL: Instead of using the SSMS GUI, use a T-SQL script. This allows you to specify the ONLINE = ON option (if you have Enterprise Edition), which can help manage how locks are held and how resources are utilized. Use the following syntax:
    ALTER TABLE TableName REBUILD WITH (DATA_COMPRESSION = PAGE);
  6. Implement Batching for Massive Tables: If the table is too large to be compressed in one operation, you cannot "batch" a single table compression, but you can move data into a new compressed table. Create a new table with the desired compression settings, then move data from the old table to the new one using INSERT INTO... SELECT in chunks of 100,000 to 500,000 rows. Once the transfer is complete, drop the old table and rename the new one.
  7. Check for Index Conflicts: Ensure that the table does not have conflicting index requirements. For example, if you are applying columnstore compression, ensure the table meets the prerequisites for columnstore indexes. Remove any unnecessary non-clustered indexes before compressing the clustered index to reduce the total log overhead, then recreate the non-clustered indexes afterward.

Common Mistakes

One of the most frequent mistakes is attempting to compress a massive table during peak business hours. Because compression is resource-heavy, it competes with active user queries for memory and CPU, often leading to Error 1730 due to resource exhaustion. Always schedule compression tasks during maintenance windows.

Another common error is ignoring the transaction log. Many administrators assume that because the final table will be smaller (compressed), the process will use less space. In reality, the process of converting data to a compressed format is a fully logged operation. If you have a 1TB table, you may need significantly more than 1TB of log space to complete the operation unless you are using the Simple Recovery Model.

Some users attempt to apply PAGE compression to tables that are already highly compressed by other means or contain data types that do not benefit from compression (like large BLOBs or encrypted columns). While this doesn't always cause Error 1730, it can lead to performance degradation and failed operations if the system struggles to find a compression gain.

Tips

To minimize the risk of Error 1730, switch your database recovery model to SIMPLE before performing a large-scale compression rebuild, provided your backup strategy allows for it. This prevents the transaction log from growing uncontrollably by allowing the log to be truncated after checkpoints.

Use the sys.dm_db_index_physical_stats dynamic management function to estimate how much space you will actually save before attempting the operation. If the estimated savings are negligible, the risk of a system-wide resource failure during the rebuild may outweigh the benefits of compression.

If you are using SQL Server Enterprise Edition, always use the ONLINE = ON flag. This allows the table to remain accessible to users and often handles the internal resource allocation more gracefully than an offline rebuild, although it may require slightly more temporary space in tempdb.

Troubleshooting

If the error persists after increasing memory and disk space, check for "blocking" sessions. A long-running transaction may be holding a lock on the table, preventing the compression rebuild from acquiring the necessary schema modification lock. Run sp_who2 or check the Activity Monitor to identify and terminate blocking processes.

If you suspect a corruption issue is triggering the failure, run DBCC CHECKDB on the database. While Error 1730 is typically a resource issue, underlying page corruption can sometimes cause the compression engine to fail when it attempts to read a page to compress it.

If the server is consistently hitting memory limits, try reducing the "Max Degree of Parallelism' (MAXDOP) for the compression operation. While SQL Server doesn't have a specific MAXDOP setting just for compression, you can limit the overall server MAXDOP or use a resource governor to cap the CPU and memory usage of the session performing the rebuild.

In extreme cases where the table is too large to rebuild and you cannot expand your disks, the only remaining path is to export the data to a flat file, truncate the original table, and re-import the data into a table that was created with compression enabled from the start. This avoids the massive transaction log overhead of an ALTER TABLE statement.

Frequently Asked Questions

Does compression slow down read queries?

Generally, no. Compression often improves read performance because fewer pages need to be read from disk into memory. However, it increases CPU usage because the data must be decompressed in memory before it can be used.

What is the difference between ROW and PAGE compression?

ROW compression looks for fixed-length types and stores them using only the space needed for the actual value. PAGE compression goes further by identifying repeating patterns across multiple rows on a page and storing them once, providing a higher compression ratio but requiring more CPU.

Can I compress a table that has a Primary Key?

Yes, you can compress tables with primary keys. In fact, compressing the clustered index (which is often the primary key) is the most common way to reduce the overall footprint of a table.

Will Error 1730 happen if I have plenty of RAM but a small SSD?

Yes. Even with ample RAM, the process requires disk space for the transaction log and tempdb. If either of these drives runs out of space during the rebuild, the operation will fail with Error 1730.

Is it possible to compress only specific columns?

Standard ROW and PAGE compression apply to the entire table or index. If you need column-level compression, you must use a Clustered Columnstore Index, which stores each column separately and compresses them individually.

Does changing the recovery model to SIMPLE delete my data?

No, changing the recovery model to SIMPLE does not delete your data. It only changes how the transaction log is managed, meaning you lose the ability to perform point-in-time recovery until you take a new full backup.