* cdbexplain_localExecStats * Called by qDisp to build NodeSummary and SliceSummary blocks * containing EXPLAIN ANALYZE statistics for a root slice that * has been executed locally in the qDisp process. Attaches these * structures to the PlanState nodes' Instrumentation objects for * later use by cdbexplain_showExecStats(). * * 'planstate' is the top PlanState node of the slice.
| 309 | * calling cdbexplain_showExecStatsBegin(). |
| 310 | */ |
| 311 | void |
| 312 | cdbexplain_localExecStats(struct PlanState *planstate, |
| 313 | struct CdbExplain_ShowStatCtx *showstatctx) |
| 314 | { |
| 315 | CdbExplain_LocalStatCtx ctx; |
| 316 | |
| 317 | Assert(Gp_role != GP_ROLE_EXECUTE); |
| 318 | |
| 319 | Assert(planstate && planstate->instrument && showstatctx); |
| 320 | |
| 321 | memset(&ctx, 0, sizeof(ctx)); |
| 322 | |
| 323 | /* Set up send context area. */ |
| 324 | ctx.send.notebuf = &showstatctx->extratextbuf; |
| 325 | |
| 326 | /* Set up a temporary StatHdr for both collecting and depositing stats. */ |
| 327 | ctx.msgptrs[0] = &ctx.send.hdr; |
| 328 | ctx.send.hdr.segindex = GpIdentity.segindex; |
| 329 | ctx.send.hdr.nInst = 1; |
| 330 | |
| 331 | /* Set up receive context area referencing our temp StatHdr. */ |
| 332 | ctx.recv.nStatInst = ctx.send.hdr.nInst; |
| 333 | ctx.recv.segindexMin = ctx.recv.segindexMax = ctx.send.hdr.segindex; |
| 334 | |
| 335 | ctx.recv.sliceIndex = LocallyExecutingSliceIndex(planstate->state); |
| 336 | ctx.recv.msgptrs = ctx.msgptrs; |
| 337 | ctx.recv.nmsgptr = 1; |
| 338 | ctx.recv.dispatchResults = NULL; |
| 339 | ctx.recv.extratextbuf = NULL; |
| 340 | ctx.recv.showstatctx = showstatctx; |
| 341 | |
| 342 | /* |
| 343 | * Collect and redeposit statistics from each PlanState node in this |
| 344 | * slice. Any extra message text will be appended directly to |
| 345 | * extratextbuf. |
| 346 | */ |
| 347 | planstate_walk_node(planstate, cdbexplain_localStatWalker, &ctx); |
| 348 | |
| 349 | /* Obtain per-slice stats and put them in SliceSummary. */ |
| 350 | cdbexplain_collectSliceStats(planstate, &ctx.send.hdr.worker); |
| 351 | cdbexplain_depositSliceStats(&ctx.send.hdr, &ctx.recv); |
| 352 | } /* cdbexplain_localExecStats */ |
| 353 | |
| 354 | |
| 355 | /* |
no test coverage detected