List *ancestors, ExplainState *es);
static void show_sortorder_options(StringInfo buf, Node *sortexpr,
Oid sortOperator, Oid collation, bool nullsFirst);
-static void show_storage_info(Tuplestorestate *tupstore, ExplainState *es);
+static void show_storage_info(char *maxStorageType, int64 maxSpaceUsed,
+ ExplainState *es);
static void show_tablesample(TableSampleClause *tsc, PlanState *planstate,
List *ancestors, ExplainState *es);
static void show_sort_info(SortState *sortstate, ExplainState *es);
static void show_hash_info(HashState *hashstate, ExplainState *es);
static void show_material_info(MaterialState *mstate, ExplainState *es);
static void show_windowagg_info(WindowAggState *winstate, ExplainState *es);
+static void show_ctescan_info(CteScanState *ctescanstate, ExplainState *es);
+static void show_table_func_scan_info(TableFuncScanState *tscanstate,
+ ExplainState *es);
+static void show_recursive_union_info(RecursiveUnionState *rstate,
+ ExplainState *es);
static void show_memoize_info(MemoizeState *mstate, List *ancestors,
ExplainState *es);
static void show_hashagg_info(AggState *aggstate, ExplainState *es);
if (plan->qual)
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
+ if (IsA(plan, CteScan))
+ show_ctescan_info(castNode(CteScanState, planstate), es);
break;
case T_Gather:
{
if (plan->qual)
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
+ show_table_func_scan_info(castNode(TableFuncScanState,
+ planstate), es);
break;
case T_TidScan:
{
show_memoize_info(castNode(MemoizeState, planstate), ancestors,
es);
break;
+ case T_RecursiveUnion:
+ show_recursive_union_info(castNode(RecursiveUnionState,
+ planstate), es);
+ break;
default:
break;
}
* Show information on storage method and maximum memory/disk space used.
*/
static void
-show_storage_info(Tuplestorestate *tupstore, ExplainState *es)
+show_storage_info(char *maxStorageType, int64 maxSpaceUsed, ExplainState *es)
{
- char *maxStorageType;
- int64 maxSpaceUsed,
- maxSpaceUsedKB;
-
- tuplestore_get_stats(tupstore, &maxStorageType, &maxSpaceUsed);
- maxSpaceUsedKB = BYTES_TO_KILOBYTES(maxSpaceUsed);
+ int64 maxSpaceUsedKB = BYTES_TO_KILOBYTES(maxSpaceUsed);
if (es->format != EXPLAIN_FORMAT_TEXT)
{
static void
show_material_info(MaterialState *mstate, ExplainState *es)
{
+ char *maxStorageType;
+ int64 maxSpaceUsed;
+
Tuplestorestate *tupstore = mstate->tuplestorestate;
/*
if (!es->analyze || tupstore == NULL)
return;
- show_storage_info(tupstore, es);
+ tuplestore_get_stats(tupstore, &maxStorageType, &maxSpaceUsed);
+ show_storage_info(maxStorageType, maxSpaceUsed, es);
}
/*
static void
show_windowagg_info(WindowAggState *winstate, ExplainState *es)
{
+ char *maxStorageType;
+ int64 maxSpaceUsed;
+
Tuplestorestate *tupstore = winstate->buffer;
/*
if (!es->analyze || tupstore == NULL)
return;
- show_storage_info(tupstore, es);
+ tuplestore_get_stats(tupstore, &maxStorageType, &maxSpaceUsed);
+ show_storage_info(maxStorageType, maxSpaceUsed, es);
+}
+
+/*
+ * Show information on CTE Scan node, storage method and maximum memory/disk
+ * space used.
+ */
+static void
+show_ctescan_info(CteScanState *ctescanstate, ExplainState *es)
+{
+ char *maxStorageType;
+ int64 maxSpaceUsed;
+
+ Tuplestorestate *tupstore = ctescanstate->leader->cte_table;
+
+ if (!es->analyze || tupstore == NULL)
+ return;
+
+ tuplestore_get_stats(tupstore, &maxStorageType, &maxSpaceUsed);
+ show_storage_info(maxStorageType, maxSpaceUsed, es);
+}
+
+/*
+ * Show information on Table Function Scan node, storage method and maximum
+ * memory/disk space used.
+ */
+static void
+show_table_func_scan_info(TableFuncScanState *tscanstate, ExplainState *es)
+{
+ char *maxStorageType;
+ int64 maxSpaceUsed;
+
+ Tuplestorestate *tupstore = tscanstate->tupstore;
+
+ if (!es->analyze || tupstore == NULL)
+ return;
+
+ tuplestore_get_stats(tupstore, &maxStorageType, &maxSpaceUsed);
+ show_storage_info(maxStorageType, maxSpaceUsed, es);
+}
+
+/*
+ * Show information on Recursive Union node, storage method and maximum
+ * memory/disk space used.
+ */
+static void
+show_recursive_union_info(RecursiveUnionState *rstate, ExplainState *es)
+{
+ char *maxStorageType,
+ *tempStorageType;
+ int64 maxSpaceUsed,
+ tempSpaceUsed;
+
+ if (!es->analyze)
+ return;
+
+ /*
+ * Recursive union node uses two tuplestores. We employ the storage type
+ * from one of them which consumed more memory/disk than the other. The
+ * storage size is sum of the two.
+ */
+ tuplestore_get_stats(rstate->working_table, &tempStorageType,
+ &tempSpaceUsed);
+ tuplestore_get_stats(rstate->intermediate_table, &maxStorageType,
+ &maxSpaceUsed);
+
+ if (tempSpaceUsed > maxSpaceUsed)
+ maxStorageType = tempStorageType;
+
+ maxSpaceUsed += tempSpaceUsed;
+ show_storage_info(maxStorageType, maxSpaceUsed, es);
}
/*