v.23.2Improvement
Support Optimizing WHERE Clause with Sorting Key Movement to PREWHERE for FINAL Queries
Support optimizing thewhereclause with sorting key expression move toprewherefor query withfinal. #38893. #38950 (hexiaoting).
Why it matters
This feature improves query performance by enabling ClickHouse to push filtering conditions that involve sorting key expressions from theWHERE 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 theFINAL keyword, ClickHouse automatically optimizes by moving applicable sorting key expressions from WHERE to PREWHERE where possible to improve performance.