Skip to content

Conversation

@va24nsh
Copy link

@va24nsh va24nsh commented Nov 9, 2025

Which issue does this PR close?

Rationale for this change

Currently, EXPLAIN ANALYZE for ProjectionExec only shows aggregated metrics like total elapsed compute time, but doesn't provide visibility into how much time individual expressions within the projection consume. This makes it difficult to identify performance bottlenecks when debugging slow queries with complex projection expressions.

What changes are included in this PR?

1. Enhanced ProjectionExec with per-expression timing metrics:
- Added per-expression Time metrics collection in ProjectionStream
- Each projection expression gets its own timer using the expression alias as the metric name
- Metrics are properly registered with the execution plan's metrics set

2. Extended metrics display in EXPLAIN ANALYZE:
- Modified display.rs to detect ProjectionExec plans
- Added get_projection_expr_metrics() helper function to extract per-expression timing data
- Enhanced metrics output to include per-expression times alongside standard metrics

3. Added intelligent time formatting:
- Implemented proper time unit formatting (ns, μs, ms, s) based on duration magnitude
- Maintains consistency with DataFusion's existing time formatting standards

Are these changes tested?

Yes - The tests have been added to check the proper functionality of latest functions.

Are there any user-facing changes?

Yes - This is an enhancement to the existing EXPLAIN ANALYZE functionality

@github-actions github-actions bot added the physical-plan Changes to the physical-plan crate label Nov 9, 2025
@2010YOUY01
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants