---
title: "How ClickHouse makes Top-N queries faster with granule-level data skipping"
description: "ClickHouse can now use minmax data-skipping indexes to prune whole granules for ORDER BY … LIMIT N queries before reading any rows."
url: "https://swe.quest/articles/how-clickhouse-makes-top-n-queries-faster-with-granule-level-data-skipping-c5fa6e048ea4d950"
canonical: "https://clickhouse.com/blog/clickhouse-top-n-queries-granule-level-data-skipping"
source: "ClickHouse"
published: "2026-01-19"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 9
tags: ["query-engines","analytics","performance","databases"]
---

# How ClickHouse makes Top-N queries faster with granule-level data skipping

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-01-19, 9 min read, Deep dive. Original: [https://clickhouse.com/blog/clickhouse-top-n-queries-granule-level-data-skipping](https://clickhouse.com/blog/clickhouse-top-n-queries-granule-level-data-skipping)

## Summary

ClickHouse can now use minmax data-skipping indexes to prune whole granules for ORDER BY … LIMIT N queries before reading any rows. Without predicates, it preselects only the granules with the smallest min (or largest max) values. With predicates, it keeps a dynamic N-th-value threshold during streaming execution and skips granules whose min/max cannot improve the result. On the 100M-row hits dataset, enabling use\_skip\_indexes\_for\_top\_k and use\_top\_k\_dynamic\_filtering made Top-N queries 5–10× faster and cut data read by 10–100×, and a 50B-row production table answered in under 0.2 s. The pruning composes with streaming Top-N, read-in-order and lazy reading, and it pays off most on large tables, cold caches and object storage.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)

## Prerequisites

- ClickHouse granules and MergeTree ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- data skipping indexes
- ORDER BY LIMIT query execution

## Keywords

ClickHouse, Top-N queries, minmax index, data skipping indexes, use\_skip\_indexes\_for\_top\_k, use\_top\_k\_dynamic\_filtering

## Related posts

- [Index-based pruning in ClickHouse](https://swe.quest/articles/index-based-pruning-in-clickhouse-5952b67ba993450d.md): ClickHouse · 2026-04-15 · Medium · 21 min read · Analytics & OLAP, Query engines, Storage engines, Performance engineering
  ClickHouse offers three index-based ways to skip data: the sparse primary index (one entry per 8,192-row granule), lightweight projections that store only a sort key plus a \_part\_offset pointer into the base table, and skip indexes such as minmax that keep per-granule min/max values.
- [ClickHouse Release 25.12](https://swe.quest/articles/clickhouse-release-25-12-e571148b4347f1f0.md): ClickHouse · 2026-01-14 · Hard · 18 min read · Query engines, Analytics & OLAP, Performance engineering, Databases
  ClickHouse 25.12 ships 26 features, 31 performance optimizations and 129 bug fixes, led by three query-engine speedups.
- [Streaming secondary indices: incremental, demand-driven index evaluation](https://swe.quest/articles/streaming-secondary-indices-incremental-demand-driven-index-evaluation-41766db7296ee01a.md): ClickHouse · 2026-01-12 · Medium · 4 min read · Query engines, Analytics & OLAP, Performance engineering, Databases
  ClickHouse 25.9 introduces streaming secondary indices, which check skip-index entries (minmax, set, bloom filter, vector, text) incrementally as each table granule is about to be read, instead of scanning the whole index before query execution.
- [Super charging your ClickHouse queries](https://swe.quest/articles/super-charging-your-clickhouse-queries-55ad4f3a6c2fa875.md): ClickHouse · 2022-12-15 · Medium · 15 min read · Analytics & OLAP, Performance engineering, Query engines, SQL
  ClickHouse query speed comes mainly from reading less data: a sparse primary index stores one entry per 8192-row granule and lets binary search skip blocks that can't match the WHERE clause.
- [ClickHouse Release 25.9](https://swe.quest/articles/clickhouse-release-25-9-512577de2ea7d4de.md): ClickHouse · 2025-10-02 · Medium · 10 min read · Query engines, Analytics & OLAP, Performance engineering, Search, SQL
  ClickHouse 25.9 adds automatic global join reordering, which uses a greedy algorithm plus row-count estimates or manually created column statistics to pick build/probe order across many tables.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
