v.23.2Improvement

Support Optimizing WHERE Clause with Sorting Key Movement to PREWHERE for FINAL Queries

Support optimizing the where clause with sorting key expression move to prewhere for query with final. #38893. #38950 (hexiaoting).
Support optimizing the WHERE clause by moving sorting key expressions to PREWHERE for queries using FINAL.

Why it matters

This feature improves query performance by enabling ClickHouse to push filtering conditions that involve sorting key expressions from the WHERE clause to the PREWHERE clause when queries use the FINAL modifier. This optimization reduces the amount of data read and processed, leading to faster query execution.

How to use it

Users do not need to change their queries explicitly. When running queries with the FINAL keyword, ClickHouse automatically optimizes by moving applicable sorting key expressions from WHERE to PREWHERE where possible to improve performance.