2 · MERGETREE · INDEX
run
Index in the lab: 1 granule or 218
EXPLAIN ESTIMATE SELECT count() FROM events
WHERE event_type = 'purchase'
AND toDate(ts) = '2026-09-15';
-- parts 1 rows 8192 marks 1
EXPLAIN ESTIMATE SELECT count() FROM events
WHERE player_id = 1042;
-- parts 2 rows 1785856 marks 218
-- в веб-базе + октябрь: parts 3, marks 220 (П2)
EXPLAIN ESTIMATE — how much data the query will read.
Without execution: parts, rows, marks. The main way to check ORDER BY.
Filter by key prefix — binary search; without a prefix, almost everything is read.
WORKING
WORSE
IF NECESSARY
Key prefix
Third column
Another Way
Event type and date: 1 granule out of 612; result: 4,195 purchases on September 15.
Just player_id: 218 granules, 1.8 million rows for 56 player events.
Projection or a table with ORDER BY (player_id, ts); skip index. Each one represents the cost of an insert.
No per-row B-tree and no UNIQUE. Rows with the same key are normal. The engine removes duplicates during merges