Compress Indexes

techresearch7777777 1,796 Reputation points
2022-05-04T16:28:49.823+00:00

Hello, is it correct to say if I compress a Table as example:

ALTER TABLE [dbo].[Table_Items] REBUILD WITH (DATA_COMPRESSION=PAGE);

Afterwards I don't need to run compress script for it's Clustered Index since the Clustered Index is the table?

If yes, can anyone provide script to compress all Nonclustered Indexes within a SQL 2016 user DB (excluding Clustered Indexes if above is correct)?

Thanks in advance.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,808 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 101.8K Reputation points MVP
    2022-05-04T21:40:01.083+00:00

    Afterwards I don't need to run compress script for it's Clustered Index since the Clustered Index is the table?

    Yes.

    If yes, can anyone provide script to compress all Nonclustered Indexes within a SQL 2016 user DB (excluding Clustered Indexes if above is correct)?

    To compress all indexes on a table do:

    ALTER INDEX ALL ON tbl REBUILD WITH (DATA_COMPRESSION = PAGE)
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. techresearch7777777 1,796 Reputation points
    2022-05-04T22:07:36+00:00

    Thanks Erland for confirming.

    0 comments No comments