Skip to content

Commit 4781c24

Browse files
[fix](profile) Add parser time to total time of summary profile (#55506)
1 parent a56419b commit 4781c24

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/common/profile/SummaryProfile.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ public class SummaryProfile {
352352

353353
private Map<Backend, Long> assignedWeightPerBackend;
354354

355+
public boolean parsedByConnectionProcess = false;
356+
355357
public SummaryProfile() {
356358
init();
357359
}

fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ public void executeQuery(String originStmt) throws Exception {
347347
executor = new StmtExecutor(ctx, parsedStmt);
348348
executor.getProfile().getSummaryProfile().setParseSqlStartTime(parseSqlStartTime);
349349
executor.getProfile().getSummaryProfile().setParseSqlFinishTime(parseSqlFinishTime);
350+
executor.getProfile().getSummaryProfile().parsedByConnectionProcess = true;
350351
ctx.setExecutor(executor);
351352

352353
if (cacheKeyType != null) {

fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,14 @@ private Map<String, String> getSummaryInfo(boolean isFinished) {
303303
// reference the implementation of DebugUtil.getPrettyStringMs to figure out the format
304304
if (isFinished) {
305305
builder.endTime(TimeUtils.longToTimeString(currentTimestamp));
306-
builder.totalTime(DebugUtil.getPrettyStringMs(currentTimestamp - context.getStartTime()));
306+
long executionCosts = currentTimestamp - context.getStartTime();
307+
// Execution of parser could happen before StmtExecutor is involved.
308+
if (getSummaryProfile().parsedByConnectionProcess) {
309+
builder.totalTime(DebugUtil.getPrettyStringMs(
310+
executionCosts + getSummaryProfile().getParseSqlTimeMs()));
311+
} else {
312+
builder.totalTime(DebugUtil.getPrettyStringMs(executionCosts));
313+
}
307314
}
308315
String taskState = "RUNNING";
309316
if (isFinished) {
@@ -747,6 +754,7 @@ private void parseByNereids() {
747754
getProfile().getSummaryProfile().setParseSqlStartTime(System.currentTimeMillis());
748755
statements = new NereidsParser().parseSQL(originStmt.originStmt, context.getSessionVariable());
749756
getProfile().getSummaryProfile().setParseSqlFinishTime(System.currentTimeMillis());
757+
getProfile().getSummaryProfile().parsedByConnectionProcess = false;
750758
} catch (Exception e) {
751759
throw new ParseException("Nereids parse failed. " + e.getMessage());
752760
}

0 commit comments

Comments
 (0)