gporca's Rule System: How to Read 119 Rules

The previous post covered gporca’s DP cells. This one covers rules: xforms/ contains 119 files, roughly 44K lines. At first it looks like required reading — it isn’t. Rules are highly homogeneous; understanding three of them teaches you a whole class. 1. There are only three kinds of rules Kind Role Examples Transformation Produce equivalent logical expressions inside the same group Join commutativity, associativity, predicate pushdown Implementation Turn a logical expression into an executable physical operator HashJoin, IndexScan, Sort Enforcer Insert operators to satisfy parent requirements Sort (order), Motion (distribution) Search works like this: transformations grow groups, implementations propose candidates, DP picks the cheapest per group. ...

October 20, 2026 · 3 min · daviszhen