Skip to content
Theory · ClickHouse: Columns, MergeTree, Sort Key, Partitions · lesson 6 of 13

Sort key and sparse index

The tapes in the archive do not lie at random but in order: first all the sales of the first shop by time, then of the second. Every 256th entry has a paper tab stuck to it, and the tab says which shop and which time that entry has. To find the second shop's sales, the archivist does not unwind the tape but runs his eyes over the tabs.

In this lesson

  • Granules and the sparse index
  • What the key speeds up
  • The key is not unique
  • PRIMARY KEY and ORDER BY
  • Common mistake
  • Key points