Add proactive memory reservation for background merges, enhancing the existing `merges_mutations_memory_usage_soft_limit` mechanism. `background_memory_tracker` measures memory that background tasks have *already* allocated, so `canEnqueueBackgroundTask` is purely reactive: when many merges are scheduled at the same time — for example right after a mutation
Related: https://github.com/ClickHouse/ClickHouse/pull/106189 Allow creating a `Distributed` table over a table function, in the same way the `remote`/`cluster` table functions already accept an arbitrary table expression. Previously `CREATE TABLE ... ENGINE = Distributed(...)` only accepted `Distributed(cluster, database, table[, sharding_key[, policy_name]
Closes: https://github.com/ClickHouse/ClickHouse/issues/78938 `EXPLAIN QUERY TREE` and `EXPLAIN SYNTAX` (in the analyzer) resolve the query and dump table metadata such as column names and types, but unlike `EXPLAIN PLAN` they do not build a query plan. The `SELECT` access check that the planner performs in `prepareBuildQueryPlanForTableExpression` was there
Closes: https://github.com/ClickHouse/ClickHouse/issues/47655 ### Changelog category (leave one): - Experimental Feature ### Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md): `MaterializedPostgreSQL` can now create its nested tables as `ReplicatedReplacingMergeTree`/`SharedReplacingMergeTree` for high availabilit
### Changelog category (leave one): - Performance Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Replaced the per-bucket hash map inside the `timeSeries*ToGrid` aggregate functions with a flat sorted arra
<!--- A technical comment, you are free to remove or leave it as it is when PR is created The following categories are used in the next scripts, update them accordingly utils/changelog/changelog.py tests/ci/cancel_and_rerun_workflow_lambda/app.py --> ### Changelog category (leave one): - Performance Improvement ### Changelog entry (a user-readable short desc
Enables server-side `Overlay` databases. An `Overlay` database is a read-only facade that exposes the union of the tables of several underlying databases, resolving each table name through the listed sources in order (the first source that has the table wins). DDL on the facade is rejected — it has no storage of its own — while `SELECT` and pass-through `INS
importance 20@AlyHKafouryopenpr-featuremanual approvecan be testedpr-autogenerated-docsOriginal evidence ↗
### Changelog category (leave one): - Bug Fix (user-visible misbehavior in an official stable release) ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Fix `rows_read` and `rows_before_limit_at_least` reported as 0 or
Implement the three remaining Prometheus HTTP API metadata endpoints for the `TimeSeries` engine, which previously threw `NOT_IMPLEMENTED`. These endpoints are required by Grafana's Prometheus data source for label autocomplete and the metric browser. - `/api/v1/series`: returns all series with their full label sets by querying the tags table, filtered by th
importance 20@ajonkiszopenpr-featuresubmodule changedmanual approvecan be testedcomp-promqlOriginal evidence ↗
### Company or project name _No response_ ### Describe the unexpected behaviour When using ClickHouse ENGINE = NATS with JetStream (pull mode, durable consumer), the consumer stops fetching messages after a NATS cluster failover. The TCP connection is successfully re-established (PING/PONG continues), but the JetStream pull loop does not resume. Messages rem
Part of making ClickHouse fastest spatial analytical engine on Earth https://github.com/bacek/chgeos/blob/main/BENCHMARK.md ;) ### Changelog category (leave one): - Performance Improvement ### Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md): Adds GeoParquet spatial pruning at row group and page levels to the Par
importance 19@bacekclosedpr-performancecan be testedpr-synced-to-cloudcomp-datalakeOriginal evidence ↗
This is an experimental continuation of [#3775 (2018)](https://github.com/ClickHouse/ClickHouse/pull/3775) by @alexey-milovidov, which proposed a declarative way to describe function signatures so that argument validation and return-type inference can be driven by a small DSL instead of hand-written `getReturnTypeImpl` logic per function. ### What's in this
Follow-up to #99774 (qoega's LIKE ESCAPE clause). Before this change, a query like `... WHERE col LIKE pattern ESCAPE 'c'` silently bypassed the primary key (`KeyCondition`), the text index (`TYPE text`), and the bloom-filter text indexes (`ngrambf_v1`, `tokenbf_v1`, `sparse_grams`), falling back to a full scan even on tables with such an index defined or wi
importance 19@groeneaiopenpr-improvementcan be testedholdOriginal evidence ↗
### Changelog category (leave one): - Critical Bug Fix (crash, data loss, RBAC) ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): A view with `SQL SECURITY DEFINER` or `SQL SECURITY NONE` is now an optimization barrier,
### Company or project name _No response_ ### Describe the situation After upgrading from 26.6.1 to 26.7, queries using Map subcolumns on a MergeTree became very slow on their first execution. This appears related to [#110623](https://github.com/ClickHouse/ClickHouse/pull/110623). PREWHERE costing now aggregates requested subcolumn sizes across every active
### Functions for geospatial aggregation #80186 Add three SQL aggregate functions for polygon set operations and convex hull computation: - `groupPolygonUnion` — union of polygonal geometries in a group - `groupPolygonIntersection` — intersection of polygonal geometries in a group - `groupConvexHull` — convex hull of grouped point, linear, and polygonal geom
Part of making ClickHouse fastest spatial analytical engine on Earth https://github.com/bacek/chgeos/blob/main/BENCHMARK.md ;) ### Changelog category (leave one): - Performance Improvement ### Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md): Adds `spatial_bbox` skip index for MergeTree geometry columns. The inde
Each thread accumulates up to `max_untracked_memory` (4 MiB by default) of allocations before reporting them to the server-wide `MemoryTracker`. With many threads, this unreported memory can sum to a large amount, causing the server's tracked memory usage to under-count actual consumption and leading to OOM. This PR introduces a server-level setting `additio
<!-- Linked issues and pull requests. Use full GitHub URLs, one relationship per line; delete the lines you don't need. Closes: https://github.com/ClickHouse/ClickHouse/issues/106736 --> ### Changelog category (leave one): - Bug Fix (user-visible misbehavior in an official stable release) ### Changelog entry (a [user-readable short description](https://githu
importance 18@groeneaiopenpr-bugfixcan be testedv26.6-must-backportOriginal evidence ↗
### Description We would like to try [google/nsync](https://github.com/google/nsync) mutex for ClickHouse. We used the existing microbenchmarks and did a comparison: - nsync: https://pastila.nl/?01726aec/f309fa62466e02f4514ab51b0166be86#jxPxN6DPD2sau29I1XHTmw==GCM - current: https://pastila.nl/?000ffb86/366fc7712e4de4898668d9c7ebee6d9b#nM+GdsaPsVmmynDDP8vVIQ
importance 18@chhetripradeepopenpr-performancesubmodule changedcan be testedOriginal evidence ↗
<!-- Linked issues and pull requests. Use full GitHub URLs, one relationship per line; delete the lines you don't need. Related: https://github.com/ClickHouse/ClickHouse/issues/101131 Related: https://github.com/ClickHouse/ClickHouse/pull/110459 Related: https://github.com/ClickHouse/ClickHouse/pull/101512 --> ### Changelog category (leave one): - Bug Fix (u
Closes: https://github.com/ClickHouse/ClickHouse/issues/110066 Introduces `UUID2`, a variant of the `UUID` data type with correct (lexicographic) sorting. ## Motivation For historical reasons, the `UUID` data type sorts by the *second half* of the value. This is unexpected and, in particular, hurts the performance of primary indexes built on `UUIDv7` columns
### Changelog category (leave one): - Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): `ReplicatedMergeTree` mutations now automatically prune the affected partitions based on the `WHERE` part of the query
Closes: https://github.com/ClickHouse/ClickHouse/issues/67770 Related: https://github.com/ClickHouse/ClickHouse/pull/95128 Queries over `Merge` tables and the `merge` table function can now be executed with parallel replicas, gated behind a new setting `parallel_replicas_allow_merge_tables` (default off). Previously such queries always ran on a single replic
`SpillingHashJoin::hasDelayedBlocks` was hardcoded to `true`, even in the `IN_MEMORY_JOIN` state where nothing is ever delayed. That is the flag gating the read-in-order-through-join and top-k-through-join optimizations, so wrapping a hash join for auto-spilling silently disabled both — and `max_bytes_ratio_before_external_join` defaults to `0.5`, which wrap
arrayElement and arraySlice now consume lazily replicated arrays (ColumnReplicated, produced by lazy ARRAY JOIN and JOIN under enable_lazy_columns_replication) without materializing them. Follow up of : https://github.com/ClickHouse/ClickHouse/pull/111581 and https://github.com/ClickHouse/ClickHouse/pull/111749 Closes: https://github.com/ClickHouse/ClickHous
<!-- Related: https://github.com/ClickHouse/ClickHouse/issues/2120 --> `arrayIntersect` filled its hash map from every argument and then rescanned the first one. For `arrayIntersect(a, b)` with 30 million and 5 million elements that is 35 million insertions into a map sized for the union of both, followed by 30 million lookups. A value that is missing from a
Planning a query that joins a `Merge` table with something else could take minutes and hundreds of megabytes of memory, and it was interruptible neither by `max_execution_time` nor by `KILL QUERY`, because all of it happens inside `QueryPlan::optimize`. `ReadFromMerge::createChildrenPlans` builds a separate child query tree for every source table. When the `
## What `isAlreadySorted` now returns early, right after the sort descriptors are resolved, when every sort key is a `ColumnConst`. Writing a `MergeTree` part whose sorting keys are all constant no longer walks the block doing adjacent-row comparisons to confirm an ordering that is constant by construction. Collation validation still runs before the early re
importance 18@perfloop-agentclosedpr-performancecan be testedpr-synced-to-cloudOriginal evidence ↗
A PromQL selector over a `TimeSeries` table filters the samples table with `id IN (SELECT id FROM tags WHERE <matchers>)`. For a metric with tens of thousands of series, `KeyCondition` runs its single-threaded generic exclusion search with the whole set: 284 ms per selector on a 62-billion-row part with 1.9M marks (503 ms at 8.1M marks), and rule-style queri
On-disk configuration for query result cache is provided in addition to the already existing in-memory configuration. When data is written to the cache, it will be written to both of them (write-through). When data is searched inside the cache, it is searched in memory first, then on disk. If the data is found on disk, it will be also put in memory. On-disk
<!--- Disable AI PR formatting assistant: true --> ### Changelog category (leave one): - Performance Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Add early short-circuit evaluation for logical OR/AND ex
**Use case.** `ORDER BY ... LIMIT n` over a sorted-by-something-else table with a narrow projection, e.g. ClickBench Q24/Q26: ```sql SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10; SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10; ``` The original build of https://github.com/
Related: https://github.com/ClickHouse/ClickHouse/pull/38022 Related: https://github.com/ClickHouse/ClickHouse/pull/38859 Adds `merge_use_batch_sorting_queue`, a Boolean `MergeTree` setting for ordinary `MergeTree` merges. It has no effect on merges that change rows, such as those performed by `ReplacingMergeTree` or `AggregatingMergeTree`. The setting defau
importance 17@rorylshanksopenpr-performancemanual approvecan be testedOriginal evidence ↗
### Changelog category (leave one): - Performance Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Aggregation queries without aggregate functions now use `HashSet`-based methods instead of `HashMap` (for s
When `use_statistics=1` (the default since `auto_statistics_types` was introduced), the PREWHERE optimizer sorted conditions by `estimated_row_count` alone, with `columns_size` only as a tiebreaker. This caused expensive conditions (e.g. Map column, ~500KB) to be placed before cheap ones (e.g. scalar column, ~1KB) whenever the expensive condition appeared mo
### Changelog category (leave one): - Performance Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Parsing an HTTP request that carries many query parameters or headers with the same name (for example thous
importance 17@sanjams2pr-performancecan be testedpr-synced-to-cloudOriginal evidence ↗
### Changelog category (leave one): - Bug Fix (user-visible misbehavior in an official stable release) ### Changelog entry: Fix missing lazy read and top-K read optimizations (skip-index top-K and dynamic top-K filtering) when selecting `ALIAS` columns with `WHERE ... ORDER BY ... LIMIT` on MergeTree tables. Closes: https://github.com/ClickHouse/ClickHouse/i
Closes: https://github.com/ClickHouse/ClickHouse/issues/74442 The analyzer (`resolveFunction`) now validates that the number of elements on the left side of `IN` matches the number of columns in the right-side subquery. Previously, constant folding could optimize away the `IN` expression and silently hide the mismatch: for example, `(1, 1) IN (SELECT 1)` wra
**Use case.** ClickBench Q17: ```sql SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10; ``` The trivial `GROUP BY ... LIMIT` optimization (`optimize_trivial_group_by_limit_query`, default `true`) rewrites such queries to `max_rows_to_group_by = n + offset` with `group_by_overflow_mode = 'any'`, so the aggregation stops ac
**Use case.** Multi-key `GROUP BY` over large blocks, e.g. ClickBench Q16/Q18: ```sql SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10; SELECT UserID, extract(minute FROM EventTime) AS m, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, m, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10; ``` The orig
Between the official ClickBench mainline runs of 2026-03-27 (≈26.3) and 2026-08-11 (latest stable, 26.7.x) on `c7a.metal-48xl` (192 vCPU), the `COUNT(DISTINCT ...)` queries regressed while overall hot performance stayed flat (hot geomean 0.97): | query | hot 2026-03-27 | hot 2026-08-11 | ratio | |---|---|---|---| | Q10 `SELECT MobilePhoneModel, COUNT(DISTINC
Add a new object storage type `borrow_from_cache` that allocates space in a named filesystem cache using ephemeral `FileSegment`s. Each stored object is backed by a cache segment held alive via `FileSegmentsHolder`; when released, the cache reclaims the space. Add a new metadata type `memory` that keeps all file-to-blob mappings and directory structure entir
Speeds up listing files for the `s3` table function over globbed paths, in two complementary ways. The listing was a single serial stream of `ListObjectsV2` requests paginated by a continuation token, bound by the per-request latency of S3 (~75 ms measured against `clickhouse-public-datasets`); this dominates queries over buckets with many objects. An earlie
Previously, `text`, `tokenbf_v1`, and `ngrambf_v1` indexes on `Array(String)` columns could not be used for predicates such as `arrayExists(x -> x LIKE '%needle%', arr)`. These predicates had to read every granule even though the index already stores tokens from the array elements. This PR lets index analysis use `arrayExists` lambdas where the lambda tests
importance 16@EmeraldShiftopenpr-performancecan be testedOriginal evidence ↗
Closes: https://github.com/ClickHouse/ClickHouse/issues/109893 ### Changelog category (leave one): - Bug Fix (user-visible misbehavior in an official stable release) ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Fix
importance 16@groeneaiclosedpr-bugfixcan be testedpr-synced-to-cloudOriginal evidence ↗
Related: https://github.com/ClickHouse/ClickHouse/pull/103705 ### Changelog category (leave one): - Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Improve canceling queries by `KILL QUERY` and Ctrl+C in `
Previously UInt128/UInt256/Int128/Int256 were written as `FIXED_LEN_BYTE_ARRAY`, but as little-endian. Since little-endian is not lexicographically sortable, there were no statistics and no way to prune row groups and pages. This was not intentional, but rather an accidental artifact from when Parquet serialization was first introduced in ClickHouse. However
<!-- Closes: https://github.com/ClickHouse/ClickHouse/issues/113038 --> ### Changelog category (leave one): - Performance Improvement ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Speed up query planning when column