# ClickHouse 26.5 pushes eligible top-N work below joins

> ClickHouse 26.5 optimizes eligible ORDER BY and LIMIT queries across joins; result cardinality and actual plans are the right upgrade checks.

Canonical URL: https://www.devobs.io/news/news-clickhouse-265-topn-join-pushdown/
By: Nina Patel
Published: 2026-09-06T11:58:54.645Z
Updated: 2026-09-06T11:58:54.645Z
Event date: 2026-06-01
Section: Data

ClickHouse's June 1 announcement for release 26.5 describes an optimizer change that can move `ORDER BY ... LIMIT` work below eligible joins. The [release article](https://clickhouse.com/blog/clickhouse-release-26-05) presents it as part of reducing how much data must pass through join processing.

## Eligibility matters more than the headline

The described case includes an outermost `LEFT JOIN` query whose sorting expressions depend only on the left table; the corresponding rule applies to a `RIGHT JOIN` sorted from the right. The release also optimizes `GROUP BY ... LIMIT` without ordering by retaining fewer groups, while still scanning the input.

Our analysis is that a query inventory is more valuable here than a blanket expectation of faster joins. Look for endpoints returning a small recent or ordered slice enriched from another table. Then inspect whether the new plan actually applies to those statements.

The grouping shortcut has a separate semantic boundary: without ordering, the selected groups are arbitrary. It should not be used to implement a promise such as “highest revenue categories” unless the query expresses that ordering.

## Preserve the application's result contract

For an upgrade experiment, include duplicate join keys, unmatched rows and ties in the sort order. Compare the final result set and its ordering, not just elapsed time or the number of rows reaching an operator.

Measure with the same data distribution and concurrency as the existing query. If a plan changes, keep the plan with the result so the improvement can be explained later.

Start with one high-volume top-N endpoint and its real ordering contract. A reproducible query and a before-and-after plan provide a clearer adoption case than transferring the vendor's example speedup to unrelated workloads.

## Source references

- <https://clickhouse.com/blog/clickhouse-release-26-05>
