liveBook · Manning

Prefix compression

As explained in 100 SQL Server Mistakes and How to Avoid Them

Prefix compression stores a shared prefix once and represents other values in the same column by their differences from that prefix.

Prefix compression stores a shared prefix once for repeated values in the same column on a page. It selects the longest complete prefix as an anchor, then stores other values as differences from that anchor. section 10.9

Within page compression, the process works as follows:

  • Identify a common prefix among values in one column on a data page. section 10.9
  • Store the longest complete prefix as an anchor. section 10.9
  • Store remaining values as differentials from that anchor. section 10.9
  • Track page changes through the CI record because updates can reduce compression effectiveness and trigger a rebuild decision. section 10.9

Applying page compression

Prefix compression is applied as part of page compression, for example by rebuilding ImpressionsArchive with ALTER TABLE ImpressionsArchive REBUILD WITH (DATA_COMPRESSION = PAGE). section 10.9

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains anchors, differentials, CI records, and update effects, but stops short of algorithmic implementation details.
Examples
Uses the ImpressionsArchive table, compressed-page illustrations, and an ALTER TABLE rebuild command.
What you can do after
Operate/configure page compression using ALTER TABLE and inspect its compressed page structure.
How it connects
Connects row compression, page compression, dictionary compression, data pages, and CI records.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.