MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / estimate_node_cost

Method estimate_node_cost

graphlite/src/plan/cost.rs:144–344  ·  view source on GitHub ↗

Estimate cost for a physical node

(&self, node: &PhysicalNode, stats: &Statistics)

Source from the content-addressed store, hash-verified

142
143 /// Estimate cost for a physical node
144 pub fn estimate_node_cost(&self, node: &PhysicalNode, stats: &Statistics) -> CostEstimate {
145 match node {
146 PhysicalNode::NodeSeqScan {
147 labels,
148 estimated_rows,
149 ..
150 } => self.estimate_scan_cost(*estimated_rows, labels, stats, true),
151
152 PhysicalNode::NodeIndexScan {
153 labels,
154 estimated_rows,
155 ..
156 } => self.estimate_scan_cost(*estimated_rows, labels, stats, false),
157
158 PhysicalNode::EdgeSeqScan {
159 labels,
160 estimated_rows,
161 ..
162 } => self.estimate_scan_cost(*estimated_rows, labels, stats, true),
163
164 PhysicalNode::IndexedExpand {
165 input,
166 estimated_rows,
167 ..
168 } => {
169 let mut cost = self.estimate_node_cost(input, stats);
170 let expand_cost = self.estimate_expand_cost(*estimated_rows, false);
171 cost.add(&expand_cost);
172 cost
173 }
174
175 PhysicalNode::HashExpand {
176 input,
177 estimated_rows,
178 ..
179 } => {
180 let mut cost = self.estimate_node_cost(input, stats);
181 let expand_cost = self.estimate_expand_cost(*estimated_rows, true);
182 cost.add(&expand_cost);
183 cost
184 }
185
186 PhysicalNode::Filter {
187 input, selectivity, ..
188 } => {
189 let mut cost = self.estimate_node_cost(input, stats);
190 let filter_cost = self.estimate_filter_cost(input.get_row_count(), *selectivity);
191 cost.add(&filter_cost);
192 cost
193 }
194
195 PhysicalNode::Project {
196 input,
197 estimated_rows,
198 ..
199 } => {
200 let mut cost = self.estimate_node_cost(input, stats);
201 let project_cost = self.estimate_project_cost(*estimated_rows);

Callers 1

estimate_plan_costMethod · 0.80

Calls 8

estimate_scan_costMethod · 0.80
estimate_expand_costMethod · 0.80
estimate_filter_costMethod · 0.80
get_row_countMethod · 0.80
estimate_project_costMethod · 0.80
estimate_join_costMethod · 0.80
estimate_sort_costMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected