-
Notifications
You must be signed in to change notification settings - Fork 25.8k
ESQL - Add planning detailed timing to profile information #138564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carlosdelest
merged 29 commits into
elastic:main
from
carlosdelest:enhancement/esql-profile-planning-time
Dec 9, 2025
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c4e50cb
Add plan profiling
d47fa65
Add plan profiling
aaa044b
Add logical / physical planning info to main plan
bb67cb9
Add logical / physical planning info to main plan
93412cb
Add transport versions
d1a1ab5
Update docs/changelog/138564.yaml
carlosdelest eadcc23
[CI] Auto commit changes from spotless
3163150
Fix serialization
077e7a3
Add test
5e61597
Merge remote-tracking branch 'carlosdelest/enhancement/esql-profile-p…
2f8bb1c
Fix changelog
3ce645d
Merge remote-tracking branch 'origin/main' into enhancement/esql-prof…
6f917f9
Remove plan time from profiling
carlosdelest 8aa8c76
Add reduction plan
carlosdelest 9cc0d6d
Merge remote-tracking branch 'origin/main' into enhancement/esql-prof…
carlosdelest f809ad0
Fix transport version
carlosdelest 656b605
[CI] Auto commit changes from spotless
87788f1
Merge branch 'main' into enhancement/esql-profile-planning-time
carlosdelest 39eebe8
Merge branch 'main' into enhancement/esql-profile-planning-time
carlosdelest 8ea6fa3
Merge remote-tracking branch 'origin/main' into enhancement/esql-prof…
carlosdelest 1eb1220
Fix transport version
carlosdelest 779cee9
Fix merge
carlosdelest 6943d54
Merge remote-tracking branch 'origin/main' into enhancement/esql-prof…
carlosdelest 6be487f
Fix profiling
carlosdelest b7ce206
Merge remote-tracking branch 'origin/main' into enhancement/esql-prof…
carlosdelest 42ef455
Add transport version after merge
carlosdelest 72e3591
Add transport version after merge
carlosdelest 9046c66
Fix serverless test
carlosdelest 9bdeede
Merge remote-tracking branch 'origin/main' into enhancement/esql-prof…
carlosdelest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 138564 | ||
| summary: ESQL - Add planning detailed timing to profile information | ||
| area: "ES|QL" | ||
| type: enhancement | ||
| issues: [] |
1 change: 1 addition & 0 deletions
1
server/src/main/resources/transport/definitions/referable/plan_profile_version.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 9236000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| inference_ccm_enablement_service,9235000 | ||
| plan_profile_version,9236000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
...plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/PlanTimeProfile.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.compute.operator; | ||
|
|
||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.xcontent.ToXContentObject; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Profile information for plan optimization phases. | ||
| * Captures timing information for logical and physical optimization steps. | ||
| * | ||
| */ | ||
| public final class PlanTimeProfile implements Writeable, ToXContentObject { | ||
| private long reductionPlanNanos; | ||
| private long logicalOptimizationNanos; | ||
| private long physicalOptimizationNanos; | ||
|
|
||
| /** | ||
| * @param logicalOptimizationNanos Time spent on local logical plan optimization (in nanoseconds) | ||
| * @param physicalOptimizationNanos Time spent on local physical plan optimization (in nanoseconds) | ||
| * @param reductionPlanNanos Time spent on reduction plan for node_reduce phase (in nanoseconds) | ||
| */ | ||
| public PlanTimeProfile(long logicalOptimizationNanos, long physicalOptimizationNanos, long reductionPlanNanos) { | ||
| this.logicalOptimizationNanos = logicalOptimizationNanos; | ||
| this.physicalOptimizationNanos = physicalOptimizationNanos; | ||
| this.reductionPlanNanos = reductionPlanNanos; | ||
| } | ||
|
|
||
| public PlanTimeProfile() { | ||
| this.logicalOptimizationNanos = 0L; | ||
| this.physicalOptimizationNanos = 0L; | ||
| this.reductionPlanNanos = 0L; | ||
| } | ||
|
|
||
| public PlanTimeProfile(StreamInput in) throws IOException { | ||
| this(in.readVLong(), in.readVLong(), in.readVLong()); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeVLong(logicalOptimizationNanos); | ||
| out.writeVLong(physicalOptimizationNanos); | ||
| out.writeVLong(reductionPlanNanos); | ||
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
| if (logicalOptimizationNanos > 0) { | ||
| builder.field("logical_optimization_nanos", logicalOptimizationNanos); | ||
| } | ||
| if (physicalOptimizationNanos > 0) { | ||
| builder.field("physical_optimization_nanos", physicalOptimizationNanos); | ||
| } | ||
| if (reductionPlanNanos > 0) { | ||
| builder.field("reduction_nanos", physicalOptimizationNanos); | ||
| } | ||
| return builder; | ||
| } | ||
|
|
||
| public void addLogicalOptimizationPlanTime(long logicalOptimizationPlanTime) { | ||
| this.logicalOptimizationNanos = this.logicalOptimizationNanos + logicalOptimizationPlanTime; | ||
| } | ||
|
|
||
| public void addPhysicalOptimizationPlanTime(long physicalOptimizationPlanTime) { | ||
| this.physicalOptimizationNanos = this.physicalOptimizationNanos + physicalOptimizationPlanTime; | ||
| } | ||
|
|
||
| public void addReductionPlanNanos(long reductionPlanNanos) { | ||
| this.reductionPlanNanos = this.reductionPlanNanos + reductionPlanNanos; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (obj == this) return true; | ||
| if (obj == null || obj.getClass() != this.getClass()) return false; | ||
| var that = (PlanTimeProfile) obj; | ||
| return this.logicalOptimizationNanos == that.logicalOptimizationNanos | ||
| && this.physicalOptimizationNanos == that.physicalOptimizationNanos | ||
| && this.reductionPlanNanos == that.reductionPlanNanos; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(logicalOptimizationNanos, physicalOptimizationNanos, reductionPlanNanos); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "PlanTimeProfile[" | ||
| + "logicalOptimizationNanos=" | ||
| + logicalOptimizationNanos | ||
| + ", " | ||
| + "physicalOptimizationNanos=" | ||
| + physicalOptimizationNanos | ||
| + ", " | ||
| + "reductionPlanNanos=" | ||
| + reductionPlanNanos | ||
| + ']'; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to move my prior question here: #138400 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking at it now - as you say, it's fairly cheap and probably makes no sense as it addresses multiple intermediate operations for planning.
I will remove it as it adds some confusion. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a
reduction_nanosfield for taking into account the reduction plan timing onnode_reduce. LMKWYT!