MCPcopy Create free account
hub / github.com/apache/cloudberry / ExplainPrintSliceTable

Function ExplainPrintSliceTable

src/backend/commands/explain.c:1058–1117  ·  view source on GitHub ↗

* ExplainPrintSliceTable - * convert the MPP slice table text and append it to es->str */

Source from the content-addressed store, hash-verified

1056 * convert the MPP slice table text and append it to es->str
1057 */
1058void
1059ExplainPrintSliceTable(ExplainState *es, QueryDesc *queryDesc)
1060{
1061 SliceTable *sliceTable = queryDesc->estate->es_sliceTable;
1062 int numSlices = (sliceTable ? sliceTable->numSlices : 0);
1063
1064 ExplainOpenGroup("Slice Table", "Slice Table", false, es);
1065
1066 for (int i = 0; i < numSlices; i++)
1067 {
1068 ExecSlice *slice = &sliceTable->slices[i];
1069 const char *gangType = "???";
1070
1071 switch (slice->gangType)
1072 {
1073 case GANGTYPE_UNALLOCATED:
1074 gangType = "Dispatcher";
1075 break;
1076 case GANGTYPE_ENTRYDB_READER:
1077 gangType = "Entry DB Reader";
1078 break;
1079 case GANGTYPE_SINGLETON_READER:
1080 gangType = "Singleton Reader";
1081 break;
1082 case GANGTYPE_PRIMARY_READER:
1083 gangType = "Reader";
1084 break;
1085 case GANGTYPE_PRIMARY_WRITER:
1086 gangType = "Primary Writer";
1087 break;
1088 }
1089
1090 if (es->format == EXPLAIN_FORMAT_TEXT)
1091 {
1092 appendStringInfo(es->str, "Slice %d: %s; root %d; parent %d; gang size %d",
1093 i,
1094 gangType,
1095 slice->rootIndex,
1096 slice->parentIndex,
1097 list_length(slice->segments));
1098 if (slice->gangType == GANGTYPE_SINGLETON_READER)
1099 appendStringInfo(es->str, "; segment %d", linitial_int(slice->segments));
1100 appendStringInfoString(es->str, "\n");
1101 }
1102 else
1103 {
1104 ExplainOpenGroup("Slice", NULL, true, es);
1105 ExplainPropertyInteger("Slice ID", NULL, i, es);
1106 ExplainPropertyText("Gang Type", gangType, es);
1107 ExplainPropertyInteger("Root", NULL, slice->rootIndex, es);
1108 ExplainPropertyInteger("Parent", NULL, slice->parentIndex, es);
1109 ExplainPropertyInteger("Gang Size", NULL, list_length(slice->segments), es);
1110 if (slice->gangType == GANGTYPE_SINGLETON_READER)
1111 ExplainPropertyInteger("Segment", NULL, linitial_int(slice->segments), es);
1112 ExplainCloseGroup("Slice", NULL, true, es);
1113 }
1114 }
1115

Callers 1

ExplainOnePlanFunction · 0.85

Calls 7

ExplainOpenGroupFunction · 0.85
appendStringInfoFunction · 0.85
list_lengthFunction · 0.85
appendStringInfoStringFunction · 0.85
ExplainPropertyIntegerFunction · 0.85
ExplainPropertyTextFunction · 0.85
ExplainCloseGroupFunction · 0.85

Tested by

no test coverage detected