Estimate cost for a physical node
(&self, node: &PhysicalNode, stats: &Statistics)
| 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); |
no test coverage detected