Rewrite Engine
See how Isofold transforms queries to reduce cost while preserving results.
Inside the Rewrite Engine
The rewrite engine is Isofold’s core logic layer. It takes an incoming SQL query, analyzes its structure and semantics, and emits a transformed version that:
- Is semantically equivalent
- Is cheaper to execute
- Returns identical results
Optimization Passes
Isofold uses a series of transformation passes on incoming queries:
✅ Projection Pruning
Remove unused columns from SELECT *
or overly wide result sets.
✅ Subquery Flattening
Flatten nested SELECTs or CTEs where they don’t affect semantics.
✅ Join Elision
Remove unnecessary joins (e.g. when a join is non-contributory to the result).
✅ Constant Folding & Simplification
Collapse constant expressions and simplify conditionals for better planning.
Cost Awareness
Isofold tracks which rewrites reduce costs without increasing compute time or result size. It can optionally test:
- Before/after query cost (e.g. using BigQuery dry-run mode)
- Byte scan reduction
- Slot time / compute usage
Rewrite Safety
All rewrites are:
- Verified for structural equivalence where possible
- Testable via the
/verify
API or dashboard - Auditable through logs and side-by-side comparisons
You can configure Isofold to apply:
- Safe rewrites only (minimal risk)
- Aggressive rewrites (more savings, potential caveats)
Custom Rules (Coming Soon)
Isofold will soon support user-defined rewrite policies to:
- Enforce column projections
- Rewrite expensive patterns
- Apply warehouse-specific hints
Continue to the Topology Overview to understand how requests flow through the system.