Overview
ClickHouse 25.12 release introduces significant performance optimizations including faster Top-N queries using granule-level data skipping indexes (5-10x speedup), a redesigned lazy reading execution model using join-style materialization (75x faster), and a more powerful DPsize join reordering algorithm. The release also promotes the text index to beta status and adds new SQL functions including dictGetKeys, non-constant IN clauses, and HMAC for webhook authentication.
What You'll Learn
How ClickHouse uses granule-level min/max metadata to skip irrelevant data in Top-N queries, achieving 5-10x speedups
How the join-style lazy materialization model replaces row-by-row lookups to achieve 75x faster query execution for large LIMIT values
How the DPsize dynamic programming algorithm explores more join orders than greedy approaches to produce more efficient execution plans
How to use ClickHouse's beta text index with tokenizers for full-text search queries
How to use the HMAC function to validate webhook signatures and build secure webhook ingestion pipelines in ClickHouse
Prerequisites & Requirements
- Understanding of SQL query execution, including ORDER BY, LIMIT, and JOIN operations
- Familiarity with ClickHouse's MergeTree storage engine and granule-based data organization
- Basic understanding of query optimization concepts like data skipping indexes and join reordering(optional)
- ClickHouse server version 25.12 or later
- Experience writing analytical SQL queries with joins, aggregations, and ordering
Key Questions Answered
How does ClickHouse 25.12 make Top-N queries faster with data skipping indexes?
What is lazy materialization in ClickHouse and how was it improved in 25.12?
What is the DPsize join reordering algorithm in ClickHouse?
How does ClickHouse's text index work and what tokenizers are available?
How can ClickHouse be used as a webhook endpoint with HMAC signature validation?
What is the dictGetKeys function in ClickHouse 25.12?
What changed with non-constant IN clauses in ClickHouse 25.12?
How does DPsize compare to greedy join reordering in ClickHouse performance?
Key Statistics & Figures
Technologies & Tools
Some links below are affiliate links. We may earn a commission if you make a purchase.
Key Actionable Insights
1Upgrade to ClickHouse 25.12 to automatically benefit from granule-level data skipping on Top-N queries. The optimization applies both statically and dynamically, reducing data reads by 1-2 orders of magnitude and speeding up ORDER BY ... LIMIT N queries by 5-10x without any query changes.This is especially impactful for dashboards, monitoring systems, and ranking reports that frequently use Top-N patterns. Benefits are largest on large tables and cold cache scenarios.
2Increase your LIMIT values confidently with the new lazy materialization model. The default query_plan_max_limit_for_lazy_materialization has been raised from 10 to 10,000, and the join-style execution model makes large LIMIT values 75x faster than the previous row-by-row approach.Previously, lazy reading with large LIMIT values was slower than eager reading due to per-row overhead. The new batched join approach eliminates this limitation, making it viable for queries returning thousands of rows.
3Enable DPsize join reordering for complex multi-table INNER JOIN queries by setting query_plan_optimize_join_order_algorithm='dpsize,greedy'. This explores more join orderings than greedy alone and falls back gracefully.The benefit grows with query complexity. For simple joins, greedy may suffice, but for queries joining many tables with varying sizes, DPsize can find significantly better execution plans. Currently experimental and limited to INNER JOINs.
4When using the text index for full-text search, prefer hasToken, hasAllTokens, and hasAnyTokens functions over LIKE patterns. The text index only activates when complete tokens can be extracted from the search term, meaning LIKE '%term%' won't use it.If you must use LIKE, add spaces around the search term (e.g., '% OpenAI %') to allow token extraction. Note this may return fewer results since it requires the term to appear as a standalone token rather than a substring.
5Use the new HMAC function to build secure webhook ingestion pipelines directly in ClickHouse. Combine staging tables, materialized views, and HMAC signature validation to filter authenticated payloads without external middleware.This requires enabling allow_get_client_http_header in the ClickHouse profile configuration. The pattern uses a staging table for all incoming payloads and a materialized view that forwards only signature-verified records to a production table.
6Leverage dictGetKeys for reverse dictionary lookups when you need to find all keys matching a specific attribute value. This enables efficient 'find all X where attribute = Y' queries on dictionaries without scanning the entire dataset.The function includes an automatic per-query cache, making bulk reverse lookups fast. Cache size is configurable via max_reverse_dictionary_lookup_cache_size_bytes.