From 01bdb5e7967d319704045b173ae153530737e230 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 13 Feb 2026 16:09:27 -0500 Subject: [PATCH 1/2] docs: Document that adding new optimizer rules are expensive --- datafusion/optimizer/src/optimizer.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/datafusion/optimizer/src/optimizer.rs b/datafusion/optimizer/src/optimizer.rs index 118ddef49b7e7..8a6282fcb131e 100644 --- a/datafusion/optimizer/src/optimizer.rs +++ b/datafusion/optimizer/src/optimizer.rs @@ -236,6 +236,14 @@ impl Default for Optimizer { impl Optimizer { /// Create a new optimizer using the recommended list of rules pub fn new() -> Self { + // NOTEs: + // + // - The order of rules in this list is important, as it determines the + // order in which they are applied. + // + // - Adding a new rule here is expensive as it will be applied to all + // queries, and will likely increase the optimization time. Please extend + // existing rules when possible, rather than adding a new rule. let rules: Vec> = vec![ Arc::new(RewriteSetComparison::new()), Arc::new(OptimizeUnions::new()), From e15eb70a33434e1dffd8f7b4030c2d7c57e33263 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 13 Feb 2026 16:10:27 -0500 Subject: [PATCH 2/2] docs: Document that adding new optimizer rules are expensive --- datafusion/optimizer/src/optimizer.rs | 2 -- datafusion/physical-optimizer/src/optimizer.rs | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/datafusion/optimizer/src/optimizer.rs b/datafusion/optimizer/src/optimizer.rs index 8a6282fcb131e..08f0b3919e907 100644 --- a/datafusion/optimizer/src/optimizer.rs +++ b/datafusion/optimizer/src/optimizer.rs @@ -237,10 +237,8 @@ impl Optimizer { /// Create a new optimizer using the recommended list of rules pub fn new() -> Self { // NOTEs: - // // - The order of rules in this list is important, as it determines the // order in which they are applied. - // // - Adding a new rule here is expensive as it will be applied to all // queries, and will likely increase the optimization time. Please extend // existing rules when possible, rather than adding a new rule. diff --git a/datafusion/physical-optimizer/src/optimizer.rs b/datafusion/physical-optimizer/src/optimizer.rs index ff71c9ec64385..49225db03ac48 100644 --- a/datafusion/physical-optimizer/src/optimizer.rs +++ b/datafusion/physical-optimizer/src/optimizer.rs @@ -82,6 +82,12 @@ impl Default for PhysicalOptimizer { impl PhysicalOptimizer { /// Create a new optimizer using the recommended list of rules pub fn new() -> Self { + // NOTEs: + // - The order of rules in this list is important, as it determines the + // order in which they are applied. + // - Adding a new rule here is expensive as it will be applied to all + // queries, and will likely increase the optimization time. Please extend + // existing rules when possible, rather than adding a new rule. let rules: Vec> = vec![ // If there is a output requirement of the query, make sure that // this information is not lost across different rules during optimization.