Skip to content

Backport #102921 to 25.8: Disable trivial LIMIT optimization with row policies/additional_table_filters - #104148

Merged
azat merged 3 commits into
25.8from
backport/25.8/102921
May 6, 2026
Merged

azat merged 3 commits into
25.8from
backport/25.8/102921

Conversation

@robot-ch-test-poll4

@robot-ch-test-poll4 robot-ch-test-poll4 commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #102921
Cherry-pick pull-request #104040

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 25.8.24.3

@robot-ch-test-poll4 robot-ch-test-poll4 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels May 5, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [37e92a0]

@azat

azat commented May 6, 2026

Copy link
Copy Markdown
Member

Stateless tests (amd_asan, distributed plan, parallel, 1/2) — Failed: 2, Passed: 3912, Skipped: 57

EXPLAIN PIPELINE
SELECT id
FROM t_row_policy_limit
LIMIT 1
SETTINGS max_threads = 4, additional_table_filters = {'t_row_policy_limit':'id < 500'}

Query id: 76eae7ca-9d11-4c8f-9d72-0d8c361fd416

   ┌─explain──────────────────────────────────────────────────────────┐
1. │ (Expression)                                                     │
2. │ ExpressionTransform × 4                                          │
3. │   (Limit)                                                        │
4. │   Limit 4 → 4                                                    │
5. │     (ReadFromMergeTree)                                          │
6. │     MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 4 0 → 1 │
   └──────────────────────────────────────────────────────────────────┘

6 rows in set. Elapsed: 0.003 sec.

:) select count() from t_row_policy_limit

SELECT count()
FROM t_row_policy_limit

Query id: 65565d67-d079-466c-8f84-faa957993e51

   ┌─count()─┐
1. │    4000 │
   └─────────┘

1 row in set. Elapsed: 0.002 sec.

:) select count() from t_row_policy_limit SETTINGS max_threads = 4, additional_table_filters = {'t_row_policy_limit':'id < 500'}

SELECT count()
FROM t_row_policy_limit
SETTINGS max_threads = 4, additional_table_filters = {'t_row_policy_limit':'id < 500'}

Query id: 9ba04370-c997-4065-b569-c4f102491c02

   ┌─count()─┐
1. │    2000 │
   └─────────┘

1 row in set. Elapsed: 0.005 sec.

@azat
azat merged commit 1c59144 into 25.8 May 6, 2026
32 of 34 checks passed
@azat
azat deleted the backport/25.8/102921 branch May 6, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants