Skip to content

Commit

Permalink
Don't maintain ancestors' list if deparsing is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Sep 6, 2024
1 parent d4c7e04 commit d92b743
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit d92b743

Please sign in to comment.