JonyTony opened a new issue, #6006: URL: https://github.com/apache/arrow-datafusion/issues/6006
### Is your feature request related to a problem or challenge? I try to read table from MemTable which is large, but when I collect it, datafusion cost more time then expectation. I find this is because logical_plan optimize. https://github.com/apache/arrow-datafusion/blob/f9f40bf70a9b6af4345f16b906bcf8a839d5f511/datafusion/core/src/execution/context.rs ```rust // line 1940 pub async fn create_physical_plan( &self, logical_plan: &LogicalPlan, ) -> Result<Arc<dyn ExecutionPlan>> { let logical_plan = self.optimize(logical_plan)?; self.query_planner .create_physical_plan(&logical_plan, self) .await } ``` I find old_plan is TableScan{.., projection: None, ..}, but new_plan is TableScan{.., projection: Some([0,1,2,...]), ..}. when I collect data, datafusion use new_plan will cost more time then use old_plan because of MemoryStream::poll_next: https://github.com/apache/arrow-datafusion/blob/f9f40bf70a9b6af4345f16b906bcf8a839d5f511/datafusion/core/src/physical_plan/memory.rs ```rust // line 203 let batch = match self.projection.as_ref() { Some(columns) => batch.project(columns)?, None => batch.clone(), }; ``` ### Describe the solution you'd like _No response_ ### Describe alternatives you've considered _No response_ ### Additional context _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
