Skip to content
Exercise · ClickHouse: Columns, MergeTree, Sort Key, Partitions · lesson 8 of 13

Exercise: a table for item sales

Analysts often count the sales of one menu item over a time range: WHERE item_id = 5 AND ts >= … AND ts < …. The sorting key of order_lines is (shop_id, ts), so the index barely helps such a query: it reads almost every granule of the months it needs.