v.20.10Improvement
ClickHouse Improvement: Addressing Non-Monotonic Binary Operators in Partition Expression Handling
ClickHouse treats partition expr and key expr differently. Partition expr is used to construct an minmax index containing related columns, while primary key expr is stored as an expr. Sometimes user might partition a table at coarser levels, such as partition by i / 1000. However, binary operators are not monotonic and this PR tries to fix that. It might also benifit other use cases. #14513 (Amos Bird).Why it matters
Partition expressions in ClickHouse determine the construction of minmax indices, which optimize query performance. Previously, using non-monotonic binary operators (e.g., expressions likepartition by i / 1000) in partitioning caused inefficiencies or incorrect indexing. This feature addresses these issues by correctly interpreting such expressions, resulting in better partition pruning and query optimization.How to use it
Users can apply this feature by defining partition expressions that include binary operators without manually modifying the expressions. For example, specifyingPARTITION BY i / 1000 in table definitions now benefits from enhanced monotonicity handling automatically.