@@ -132,6 +132,7 @@ static void ExplainQueryType(DistributedSpatiotemporalQueryPlan *distPlan, Expla
132132 ExplainPropertyText ("Distributed Spatiotemporal Planner" , temp -> data , es );
133133}
134134
135+ /* getQueryType renders the combination of chosen strategies as a short human-readable label. */
135136static char * getQueryType (List * strategies )
136137{
137138 ListCell * cell = NULL ;
@@ -222,6 +223,13 @@ static void ExplainQueryPlan(DistributedSpatiotemporalQueryPlan *distPlan, Expla
222223 }
223224}
224225
226+ /*
227+ * ExplainPlanStrategies re-runs the executor in explain-only mode
228+ * (RunQueryExecutor with explain=true, so no data-modifying SPI calls
229+ * happen) to obtain the per-strategy tasks, then prints one representative
230+ * task per task type via ExplainOneTask — showing the plan for a single
231+ * tile stands in for all `candidates` tiles that would actually run.
232+ */
225233static void
226234ExplainPlanStrategies (DistributedSpatiotemporalQueryPlan * distPlan , ExplainState * es , int indent_group )
227235{
@@ -242,6 +250,12 @@ ExplainPlanStrategies(DistributedSpatiotemporalQueryPlan *distPlan, ExplainState
242250 es -> indent -= 5 ;
243251 }
244252}
253+ /*
254+ * ExplainOneTask plans and (via ExplainWorkerPlan) prints the local plan
255+ * for a single, randomly-chosen tile of `task`, substituting that tile's
256+ * concrete shard identifier into the task's query (GetLocalQuery) so it
257+ * can be planned as an ordinary local query.
258+ */
245259static void
246260ExplainOneTask (ExecutorTask * task , STMultirelation * base ,ExplainState * es , int indent_group )
247261{
@@ -267,6 +281,12 @@ ExplainOneTask(ExecutorTask *task, STMultirelation *base,ExplainState *es, int i
267281 ExplainEndOutput (es );
268282}
269283
284+ /*
285+ * GetLocalQuery rewrites query_string so that every distributed table name
286+ * it references is replaced by the concrete shard/tile identifier chosen
287+ * for it (GetRandomTileId), producing a plain local query that EXPLAIN can
288+ * plan directly.
289+ */
270290static char *
271291GetLocalQuery (char * query_string , Oid base , ExecTaskType taskType , int rand_tile )
272292{
0 commit comments