apache / apache/gluten

[CH]Optimize and filter conditions by move equals ahead

Open
#8,516 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Scala
Stars
1.6k
Forks
657
Avg merge
2d 14h
Merged PRs (30d)
80

Description

### Description

when do query contains multiple `and` conditions in where , just like `select count(1) from test_tbl where cast(b as string) != '' and a = 1`, we can simply move the equals conditions ahead to improve the performance, the sql can be executed as `select count(1) from test_tbl where a = 1 and cast(b as string) != ''`, below it is the performance comparsion of the two sql

![image](https://github.com/user-attachments/assets/bf89fb64-75ab-4a3b-8ee9-992ba82b5361)

![image](https://github.com/user-attachments/assets/1012b915-f53b-4d34-9462-0269be09cee4)

Contributor guide

Open the contributing guide

Research direction

No file, test, or entry point is identified in the issue. Start by locating the ClickHouse condition-processing path that handles multiple WHERE predicates, then inspect how equality and cast conditions are ordered. Done means equivalent conditions are executed with equality predicates first and the reported query-performance improvement is validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, sql
Domain
backend, databases, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.