Skip to content
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

Don't maintain ancestors' list if deparsing is disabled #55

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/pg_tracing_planstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ create_spans_from_planstate(PlanState *planstate, planstateTraceContext * planst
(IsA(planstate, CustomScanState) &&
((CustomScanState *) planstate)->custom_ps != NIL) ||
planstate->subPlan;
if (haschildren)
if (haschildren && planstateTraceContext->deparse_ctx)
planstateTraceContext->ancestors = lcons(planstate->plan, planstateTraceContext->ancestors);

/* Walk the outerplan */
Expand Down Expand Up @@ -444,7 +444,8 @@ create_spans_from_planstate(PlanState *planstate, planstateTraceContext * planst
* Push subplan as an ancestor so that we can resolve referent of
* subplan parameters.
*/
planstateTraceContext->ancestors = lcons(sp, planstateTraceContext->ancestors);
if (planstateTraceContext->deparse_ctx)
planstateTraceContext->ancestors = lcons(sp, planstateTraceContext->ancestors);

subplan_span = create_span_node(splan, planstateTraceContext,
&subplan_span_id, span_id, query_id,
Expand All @@ -453,7 +454,8 @@ create_spans_from_planstate(PlanState *planstate, planstateTraceContext * planst
child_end = create_spans_from_planstate(splan, planstateTraceContext, subplan_span.span_id, query_id, subplan_traced_planstate->node_start,
root_end, latest_end);

planstateTraceContext->ancestors = list_delete_first(planstateTraceContext->ancestors);
if (planstateTraceContext->deparse_ctx)
planstateTraceContext->ancestors = list_delete_first(planstateTraceContext->ancestors);
}

/* Handle special nodes with children nodes */
Expand Down Expand Up @@ -484,7 +486,7 @@ create_spans_from_planstate(PlanState *planstate, planstateTraceContext * planst
default:
break;
}
if (haschildren)
if (haschildren && planstateTraceContext->deparse_ctx)
planstateTraceContext->ancestors = list_delete_first(planstateTraceContext->ancestors);

/* If node had no duration, use the latest end of its child */
Expand Down