63#define BYTES_TO_KILOBYTES(b) (((b) + 1023) / 1024)
77 const char *relationship,
const char *plan_name,
105 List *context,
bool useprefix,
110 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
111 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
114 Oid sortOperator,
Oid collation,
bool nullsFirst);
194 (*post_parse_analyze_hook) (pstate, query, jstate);
207 if (rewritten ==
NIL)
221 foreach(l, rewritten)
228 if (
lnext(rewritten, l) != NULL)
258 Oid result_type = TEXTOID;
261 foreach(lc,
stmt->options)
265 if (strcmp(opt->
defname,
"format") == 0)
269 if (strcmp(p,
"xml") == 0)
270 result_type = XMLOID;
271 else if (strcmp(p,
"json") == 0)
272 result_type = JSONOID;
274 result_type = TEXTOID;
306 (*ExplainOneQuery_hook) (query, cursorOptions, into, es,
343 "explain analyze planner context",
374 &planduration, (es->
buffers ? &bufusage : NULL),
375 es->
memory ? &mem_counters : NULL);
394 if (utilityStmt == NULL)
419 elog(
ERROR,
"unexpected object type: %d",
428 (*post_parse_analyze_hook) (pstate, ctas_query, jstate);
454 (*post_parse_analyze_hook) (pstate, dcs_query, jstate);
476 "Utility statements have no plan structure\n");
506 double totaltime = 0;
508 int instrument_option = 0;
555 dest, params, queryEnv, instrument_option);
568 if (queryDesc->
cplan)
576 elog(
ERROR,
"ExecutorStart() failed unexpectedly");
636 if (es->
summary && planduration)
662 (*explain_per_plan_hook) (plannedstmt, into, es, queryString,
717 for (
int i = 0;
i < num;
i++)
739 for (
int i = 0;
i < num;
i++)
864 routerels !=
NIL || targrels !=
NIL);
865 foreach(l, resultrels)
871 foreach(l, routerels)
946 "Inlining", jit_flags &
PGJIT_INLINE ?
"true" :
"false",
947 "Optimization", jit_flags &
PGJIT_OPT3 ?
"true" :
"false",
948 "Expressions", jit_flags &
PGJIT_EXPR ?
"true" :
"false",
949 "Deforming", jit_flags &
PGJIT_DEFORM ?
"true" :
"false");
955 "Timing: %s %.3f ms (%s %.3f ms), %s %.3f ms, %s %.3f ms, %s %.3f ms, %s %.3f ms\n",
1095 if (params == NULL || params->
numParams <= 0 || maxlen == 0)
1099 if (
str &&
str[0] !=
'\0')
1119 char *conname = NULL;
1144 if (es->
verbose || conname == NULL)
1207 case T_IndexOnlyScan:
1208 case T_BitmapHeapScan:
1210 case T_TidRangeScan:
1211 case T_SubqueryScan:
1212 case T_FunctionScan:
1213 case T_TableFuncScan:
1216 case T_NamedTuplestoreScan:
1217 case T_WorkTableScan:
1260 int child_disabled_nodes;
1263 if (
plan->disabled_nodes == 0)
1266 child_disabled_nodes = 0;
1335 if (
plan->disabled_nodes > child_disabled_nodes)
1364 const char *relationship,
const char *plan_name,
1370 const char *strategy = NULL;
1371 const char *partialmode = NULL;
1372 const char *operation = NULL;
1373 const char *custom_name = NULL;
1375 int save_indent = es->
indent;
1392 pname = sname =
"Result";
1395 pname = sname =
"ProjectSet";
1398 sname =
"ModifyTable";
1402 pname = operation =
"Insert";
1405 pname = operation =
"Update";
1408 pname = operation =
"Delete";
1411 pname = operation =
"Merge";
1419 pname = sname =
"Append";
1422 pname = sname =
"Merge Append";
1424 case T_RecursiveUnion:
1425 pname = sname =
"Recursive Union";
1428 pname = sname =
"BitmapAnd";
1431 pname = sname =
"BitmapOr";
1434 pname = sname =
"Nested Loop";
1438 sname =
"Merge Join";
1442 sname =
"Hash Join";
1445 pname = sname =
"Seq Scan";
1448 pname = sname =
"Sample Scan";
1451 pname = sname =
"Gather";
1454 pname = sname =
"Gather Merge";
1457 pname = sname =
"Index Scan";
1459 case T_IndexOnlyScan:
1460 pname = sname =
"Index Only Scan";
1462 case T_BitmapIndexScan:
1463 pname = sname =
"Bitmap Index Scan";
1465 case T_BitmapHeapScan:
1466 pname = sname =
"Bitmap Heap Scan";
1469 pname = sname =
"Tid Scan";
1471 case T_TidRangeScan:
1472 pname = sname =
"Tid Range Scan";
1474 case T_SubqueryScan:
1475 pname = sname =
"Subquery Scan";
1477 case T_FunctionScan:
1478 pname = sname =
"Function Scan";
1480 case T_TableFuncScan:
1481 pname = sname =
"Table Function Scan";
1484 pname = sname =
"Values Scan";
1487 pname = sname =
"CTE Scan";
1489 case T_NamedTuplestoreScan:
1490 pname = sname =
"Named Tuplestore Scan";
1492 case T_WorkTableScan:
1493 pname = sname =
"WorkTable Scan";
1496 sname =
"Foreign Scan";
1500 pname =
"Foreign Scan";
1501 operation =
"Select";
1504 pname =
"Foreign Insert";
1505 operation =
"Insert";
1508 pname =
"Foreign Update";
1509 operation =
"Update";
1512 pname =
"Foreign Delete";
1513 operation =
"Delete";
1521 sname =
"Custom Scan";
1524 pname =
psprintf(
"Custom Scan (%s)", custom_name);
1529 pname = sname =
"Materialize";
1532 pname = sname =
"Memoize";
1535 pname = sname =
"Sort";
1537 case T_IncrementalSort:
1538 pname = sname =
"Incremental Sort";
1541 pname = sname =
"Group";
1547 sname =
"Aggregate";
1551 pname =
"Aggregate";
1555 pname =
"GroupAggregate";
1556 strategy =
"Sorted";
1559 pname =
"HashAggregate";
1560 strategy =
"Hashed";
1563 pname =
"MixedAggregate";
1567 pname =
"Aggregate ???";
1574 partialmode =
"Partial";
1575 pname =
psprintf(
"%s %s", partialmode, pname);
1579 partialmode =
"Finalize";
1580 pname =
psprintf(
"%s %s", partialmode, pname);
1583 partialmode =
"Simple";
1587 pname = sname =
"WindowAgg";
1590 pname = sname =
"Unique";
1598 strategy =
"Sorted";
1601 pname =
"HashSetOp";
1602 strategy =
"Hashed";
1605 pname =
"SetOp ???";
1611 pname = sname =
"LockRows";
1614 pname = sname =
"Limit";
1617 pname = sname =
"Hash";
1620 pname = sname =
"???";
1625 relationship ? NULL :
"Plan",
1642 if (
plan->parallel_aware)
1644 if (
plan->async_capable)
1672 case T_BitmapHeapScan:
1674 case T_TidRangeScan:
1675 case T_SubqueryScan:
1676 case T_FunctionScan:
1677 case T_TableFuncScan:
1680 case T_WorkTableScan:
1685 if (((
Scan *)
plan)->scanrelid > 0)
1698 case T_IndexOnlyScan:
1708 case T_BitmapIndexScan:
1711 const char *indexname =
1728 const char *jointype;
1751 jointype =
"Right Semi";
1754 jointype =
"Right Anti";
1777 const char *setopcmd;
1782 setopcmd =
"Intersect";
1785 setopcmd =
"Intersect All";
1788 setopcmd =
"Except";
1791 setopcmd =
"Except All";
1812 plan->startup_cost,
plan->total_cost,
1813 plan->plan_rows,
plan->plan_width);
1904 double nloops = instrument->
nloops;
1911 startup_ms = 1000.0 * instrument->
startup / nloops;
1912 total_ms = 1000.0 * instrument->
total / nloops;
1913 rows = instrument->
ntuples / nloops;
1970 "Index Cond", planstate, ancestors, es);
1975 "Order By", planstate, ancestors, es);
1982 case T_IndexOnlyScan:
1984 "Index Cond", planstate, ancestors, es);
1989 "Order By", planstate, ancestors, es);
1999 case T_BitmapIndexScan:
2001 "Index Cond", planstate, ancestors, es);
2004 case T_BitmapHeapScan:
2006 "Recheck Cond", planstate, ancestors, es);
2018 planstate, ancestors, es);
2024 case T_NamedTuplestoreScan:
2025 case T_WorkTableScan:
2026 case T_SubqueryScan:
2049 nworkers = ((
GatherState *) planstate)->nworkers_launched;
2079 case T_FunctionScan:
2093 "Function Call", planstate, ancestors,
2101 case T_TableFuncScan:
2107 "Table Function Call", planstate, ancestors,
2134 case T_TidRangeScan:
2172 "Join Filter", planstate, ancestors, es);
2183 "Merge Cond", planstate, ancestors, es);
2185 "Join Filter", planstate, ancestors, es);
2196 "Hash Cond", planstate, ancestors, es);
2198 "Join Filter", planstate, ancestors, es);
2218 "Run Condition", planstate, ancestors, es);
2236 case T_IncrementalSort:
2248 "One-Time Filter", planstate, ancestors, es);
2268 case T_RecursiveUnion:
2310 double nloops = instrument->
nloops;
2331 (*explain_per_node_hook) (planstate, ancestors, relationship,
2359 haschildren = planstate->
initPlan ||
2414 case T_SubqueryScan:
2416 "Subquery", NULL, es);
2439 es->
indent = save_indent;
2442 relationship ? NULL :
"Plan",
2491 foreach(lc,
plan->targetlist)
2559 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2573 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2585 plan->numCols, 0,
plan->sortColIdx,
2586 plan->sortOperators,
plan->collations,
2601 plan->sort.numCols,
plan->nPresortedCols,
2602 plan->sort.sortColIdx,
2603 plan->sort.sortOperators,
plan->sort.collations,
2604 plan->sort.nullsFirst,
2618 plan->numCols, 0,
plan->sortColIdx,
2619 plan->sortOperators,
plan->collations,
2638 if (
plan->groupingSets)
2667 context, useprefix, ancestors, es);
2669 foreach(lc, agg->
chain)
2675 context, useprefix, ancestors, es);
2692 const char *keyname;
2693 const char *keysetname;
2697 keyname =
"Hash Key";
2698 keysetname =
"Hash Keys";
2702 keyname =
"Group Key";
2703 keysetname =
"Group Keys";
2711 sortnode->
numCols, 0, sortnode->sortColIdx,
2712 sortnode->sortOperators, sortnode->collations,
2713 sortnode->nullsFirst,
2734 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2739 result =
lappend(result, exprstr);
2781 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
2782 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
2804 for (keyno = 0; keyno < nkeys; keyno++)
2813 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2820 if (sortOperators != NULL)
2823 sortOperators[keyno],
2828 if (keyno < nPresortedKeys)
2829 resultPresorted =
lappend(resultPresorted, exprstr);
2833 if (nPresortedKeys > 0)
2843 Oid sortOperator,
Oid collation,
bool nullsFirst)
2846 bool reverse =
false;
2863 if (collname == NULL)
2864 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2869 if (sortOperator == typentry->
gt_opr)
2874 else if (sortOperator != typentry->
lt_opr)
2879 elog(
ERROR,
"cache lookup failed for operator %u", sortOperator);
2886 if (nullsFirst && !reverse)
2890 else if (!nullsFirst && reverse)
2904 bool needspace =
false;
2910 ancestors =
lcons(wagg, ancestors);
2977 for (
int keyno = 0; keyno < nkeys; keyno++)
2986 elog(
ERROR,
"no tlist entry for key %d", keyresno);
3050 foreach(lc, tsc->
args)
3105 const char *sortMethod;
3106 const char *spaceType;
3112 spaceUsed = stats.spaceUsed;
3118 sortMethod, spaceType, spaceUsed);
3144 const char *sortMethod;
3145 const char *spaceType;
3163 sortMethod, spaceType, spaceUsed);
3217 foreach(methodCell, methodNames)
3227 const char *spaceTypeName;
3231 spaceTypeName, avgSpace,
3239 const char *spaceTypeName;
3243 spaceTypeName, avgSpace,
3261 const char *spaceTypeName;
3278 const char *spaceTypeName;
3338 bool indent_first_line;
3366 indent_first_line, es);
3434 if (hinstrument.
nbatch > 0)
3456 "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: " UINT64_FORMAT "kB\n",
3467 "Buckets: %d Batches: %d Memory Usage: " UINT64_FORMAT "kB\n",
3481 char *maxStorageType;
3490 if (!es->
analyze || tupstore == NULL)
3504 char *maxStorageType;
3513 if (!es->
analyze || tupstore == NULL)
3527 char *maxStorageType;
3532 if (!es->
analyze || tupstore == NULL)
3546 char *maxStorageType;
3551 if (!es->
analyze || tupstore == NULL)
3565 char *maxStorageType,
3583 if (tempSpaceUsed > maxSpaceUsed)
3584 maxStorageType = tempStorageType;
3586 maxSpaceUsed += tempSpaceUsed;
3759 bool gotone =
false;
3804 int hash_batches_used;
3822 hash_batches_used, memPeakKb);
3825 if (hash_batches_used > 1)
3833 hash_batches_used, es);
3870 case T_IndexOnlyScan:
3878 case T_BitmapIndexScan:
3935 if (planstate->
pstate != NULL)
4039 result = (*explain_get_index_name_hook) (indexId);
4047 elog(
ERROR,
"cache lookup failed for index %u", indexId);
4063 bool has_shared_timing;
4064 bool has_local_timing;
4065 bool has_temp_timing;
4073 has_shared = (
usage->shared_blks_hit > 0 ||
4074 usage->shared_blks_read > 0 ||
4075 usage->shared_blks_dirtied > 0 ||
4076 usage->shared_blks_written > 0);
4077 has_local = (
usage->local_blks_hit > 0 ||
4078 usage->local_blks_read > 0 ||
4079 usage->local_blks_dirtied > 0 ||
4080 usage->local_blks_written > 0);
4081 has_temp = (
usage->temp_blks_read > 0 ||
4082 usage->temp_blks_written > 0);
4090 return has_shared || has_local || has_temp || has_shared_timing ||
4091 has_local_timing || has_temp_timing;
4102 bool has_shared = (
usage->shared_blks_hit > 0 ||
4103 usage->shared_blks_read > 0 ||
4104 usage->shared_blks_dirtied > 0 ||
4105 usage->shared_blks_written > 0);
4106 bool has_local = (
usage->local_blks_hit > 0 ||
4107 usage->local_blks_read > 0 ||
4108 usage->local_blks_dirtied > 0 ||
4109 usage->local_blks_written > 0);
4110 bool has_temp = (
usage->temp_blks_read > 0 ||
4111 usage->temp_blks_written > 0);
4120 if (has_shared || has_local || has_temp)
4128 if (
usage->shared_blks_hit > 0)
4130 usage->shared_blks_hit);
4131 if (
usage->shared_blks_read > 0)
4133 usage->shared_blks_read);
4134 if (
usage->shared_blks_dirtied > 0)
4136 usage->shared_blks_dirtied);
4137 if (
usage->shared_blks_written > 0)
4139 usage->shared_blks_written);
4140 if (has_local || has_temp)
4146 if (
usage->local_blks_hit > 0)
4148 usage->local_blks_hit);
4149 if (
usage->local_blks_read > 0)
4151 usage->local_blks_read);
4152 if (
usage->local_blks_dirtied > 0)
4154 usage->local_blks_dirtied);
4155 if (
usage->local_blks_written > 0)
4157 usage->local_blks_written);
4164 if (
usage->temp_blks_read > 0)
4166 usage->temp_blks_read);
4167 if (
usage->temp_blks_written > 0)
4169 usage->temp_blks_written);
4175 if (has_shared_timing || has_local_timing || has_temp_timing)
4180 if (has_shared_timing)
4189 if (has_local_timing || has_temp_timing)
4192 if (has_local_timing)
4201 if (has_temp_timing)
4204 if (has_temp_timing)
4220 usage->shared_blks_hit, es);
4222 usage->shared_blks_read, es);
4224 usage->shared_blks_dirtied, es);
4226 usage->shared_blks_written, es);
4228 usage->local_blks_hit, es);
4230 usage->local_blks_read, es);
4232 usage->local_blks_dirtied, es);
4234 usage->local_blks_written, es);
4236 usage->temp_blks_read, es);
4238 usage->temp_blks_written, es);
4272 if ((
usage->wal_records > 0) || (
usage->wal_fpi > 0) ||
4273 (
usage->wal_bytes > 0) || (
usage->wal_buffers_full > 0))
4278 if (
usage->wal_records > 0)
4280 usage->wal_records);
4281 if (
usage->wal_fpi > 0)
4284 if (
usage->wal_bytes > 0)
4287 if (
usage->wal_buffers_full > 0)
4289 usage->wal_buffers_full);
4296 usage->wal_records, es);
4298 usage->wal_fpi, es);
4300 usage->wal_bytes, es);
4302 usage->wal_buffers_full, es);
4321 memUsedkB, memAllocatedkB);
4349 const char *scandir;
4351 switch (indexorderdir)
4354 scandir =
"Backward";
4357 scandir =
"Forward";
4396 char *objectname = NULL;
4397 char *
namespace = NULL;
4398 const char *objecttag = NULL;
4404 if (refname == NULL)
4405 refname = rte->eref->aliasname;
4412 case T_IndexOnlyScan:
4413 case T_BitmapHeapScan:
4415 case T_TidRangeScan:
4424 objecttag =
"Relation Name";
4426 case T_FunctionScan:
4453 objecttag =
"Function Name";
4456 case T_TableFuncScan:
4464 objectname =
"xmltable";
4467 objectname =
"json_table";
4470 elog(
ERROR,
"invalid TableFunc type %d",
4473 objecttag =
"Table Function Name";
4482 Assert(!rte->self_reference);
4483 objectname = rte->ctename;
4484 objecttag =
"CTE Name";
4486 case T_NamedTuplestoreScan:
4488 objectname = rte->enrname;
4489 objecttag =
"Tuplestore Name";
4491 case T_WorkTableScan:
4494 Assert(rte->self_reference);
4495 objectname = rte->ctename;
4496 objecttag =
"CTE Name";
4505 if (
namespace != NULL)
4508 else if (objectname != NULL)
4510 if (objectname == NULL || strcmp(refname, objectname) != 0)
4515 if (objecttag != NULL && objectname != NULL)
4517 if (
namespace != NULL)
4536 const char *operation;
4537 const char *foperation;
4546 operation =
"Insert";
4547 foperation =
"Foreign Insert";
4550 operation =
"Update";
4551 foperation =
"Foreign Update";
4554 operation =
"Delete";
4555 foperation =
"Foreign Delete";
4558 operation =
"Merge";
4560 foperation =
"Foreign Merge";
4564 foperation =
"Foreign ???";
4577 labeltargets = (mtstate->
mt_nrels > 1 ||
4604 fdwroutine ? foperation : operation);
4621 fdwroutine != NULL &&
4649 idxNames =
lappend(idxNames, indexname);
4656 "NOTHING" :
"UPDATE",
4670 &mtstate->
ps, ancestors, es);
4686 insert_path = total - other_path;
4689 insert_path, 0, es);
4703 double skipped_path;
4712 skipped_path = total - insert_path - update_path - delete_path;
4713 Assert(skipped_path >= 0);
4721 if (insert_path > 0)
4723 if (update_path > 0)
4725 if (delete_path > 0)
4727 if (skipped_path > 0)
4759 for (
j = 0;
j < nplans;
j++)
4761 "Member", NULL, es);
4776 nchildren - nplans, es);
4816 ancestors =
lcons(sp, ancestors);
4873 Assert(n >= 0 && n < wstate->num_workers);
4935 Assert(n >= 0 && n < wstate->num_workers);
void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es, ParseState *pstate, ParamListInfo params)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
#define unconstify(underlying_type, expr)
#define OidIsValid(objectId)
bool CreateTableAsRelExists(CreateTableAsStmt *ctas)
int GetIntoRelEFlags(IntoClause *intoClause)
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
char * defGetString(DefElem *def)
DestReceiver * None_Receiver
bool ExecutorStart(QueryDesc *queryDesc, int eflags)
void ExecutorStartCachedPlan(QueryDesc *queryDesc, int eflags, CachedPlanSource *plansource, int query_index)
void ExecutorEnd(QueryDesc *queryDesc)
void ExecutorFinish(QueryDesc *queryDesc)
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
const TupleTableSlotOps TTSOpsVirtual
void end_tup_output(TupOutputState *tstate)
void do_text_output_multiline(TupOutputState *tstate, const char *txt)
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
#define outerPlanState(node)
#define innerPlanState(node)
#define EXEC_FLAG_EXPLAIN_GENERIC
#define do_text_output_oneline(tstate, str_to_emit)
#define EXEC_FLAG_EXPLAIN_ONLY
static void show_modifytable_info(ModifyTableState *mtstate, List *ancestors, ExplainState *es)
#define BYTES_TO_KILOBYTES(b)
static void show_plan_tlist(PlanState *planstate, List *ancestors, ExplainState *es)
static void show_memoize_info(MemoizeState *mstate, List *ancestors, ExplainState *es)
static void show_group_keys(GroupState *gstate, List *ancestors, ExplainState *es)
static void ExplainModifyTarget(ModifyTable *plan, ExplainState *es)
static void show_window_def(WindowAggState *planstate, List *ancestors, ExplainState *es)
static void show_agg_keys(AggState *astate, List *ancestors, ExplainState *es)
static void show_hashagg_info(AggState *aggstate, ExplainState *es)
static void show_scan_qual(List *qual, const char *qlabel, PlanState *planstate, List *ancestors, ExplainState *es)
static const char * explain_get_index_name(Oid indexId)
static void ExplainIndexScanDetails(Oid indexid, ScanDirection indexorderdir, ExplainState *es)
ExplainOneQuery_hook_type ExplainOneQuery_hook
static void show_instrumentation_count(const char *qlabel, int which, PlanState *planstate, ExplainState *es)
static void ExplainNode(PlanState *planstate, List *ancestors, const char *relationship, const char *plan_name, ExplainState *es)
static void show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo, const char *groupLabel, bool indent, ExplainState *es)
void ExplainOnePlan(PlannedStmt *plannedstmt, CachedPlan *cplan, CachedPlanSource *plansource, int query_index, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, const instr_time *planduration, const BufferUsage *bufusage, const MemoryContextCounters *mem_counters)
static void ExplainMemberNodes(PlanState **planstates, int nplans, List *ancestors, ExplainState *es)
static void show_ctescan_info(CteScanState *ctescanstate, ExplainState *es)
explain_get_index_name_hook_type explain_get_index_name_hook
static bool ExplainPreScanNode(PlanState *planstate, Bitmapset **rels_used)
static void ExplainPrintJIT(ExplainState *es, int jit_flags, JitInstrumentation *ji)
static void show_recursive_union_info(RecursiveUnionState *rstate, ExplainState *es)
void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, ParamListInfo params, DestReceiver *dest)
static void show_incremental_sort_info(IncrementalSortState *incrsortstate, ExplainState *es)
static void show_tablesample(TableSampleClause *tsc, PlanState *planstate, List *ancestors, ExplainState *es)
static void show_upper_qual(List *qual, const char *qlabel, PlanState *planstate, List *ancestors, ExplainState *es)
static void show_sort_info(SortState *sortstate, ExplainState *es)
static void show_window_keys(StringInfo buf, PlanState *planstate, int nkeys, AttrNumber *keycols, List *ancestors, ExplainState *es)
static void ExplainMissingMembers(int nplans, int nchildren, ExplainState *es)
explain_per_node_hook_type explain_per_node_hook
TupleDesc ExplainResultDesc(ExplainStmt *stmt)
static void ExplainFlushWorkersState(ExplainState *es)
static bool peek_buffer_usage(ExplainState *es, const BufferUsage *usage)
void ExplainPrintJITSummary(ExplainState *es, QueryDesc *queryDesc)
static void show_hash_info(HashState *hashstate, ExplainState *es)
static void show_sortorder_options(StringInfo buf, Node *sortexpr, Oid sortOperator, Oid collation, bool nullsFirst)
static void show_table_func_scan_info(TableFuncScanState *tscanstate, ExplainState *es)
static void show_indexsearches_info(PlanState *planstate, ExplainState *es)
static void show_expression(Node *node, const char *qlabel, PlanState *planstate, List *ancestors, bool useprefix, ExplainState *es)
static double elapsed_time(instr_time *starttime)
void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
explain_per_plan_hook_type explain_per_plan_hook
static bool plan_is_disabled(Plan *plan)
static void show_sort_group_keys(PlanState *planstate, const char *qlabel, int nkeys, int nPresortedKeys, AttrNumber *keycols, Oid *sortOperators, Oid *collations, bool *nullsFirst, List *ancestors, ExplainState *es)
static void show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
static void show_windowagg_info(WindowAggState *winstate, ExplainState *es)
static void show_memory_counters(ExplainState *es, const MemoryContextCounters *mem_counters)
static void ExplainSubPlans(List *plans, List *ancestors, const char *relationship, ExplainState *es)
static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es)
static void ExplainScanTarget(Scan *plan, ExplainState *es)
void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
static void show_merge_append_keys(MergeAppendState *mstate, List *ancestors, ExplainState *es)
static void report_triggers(ResultRelInfo *rInfo, bool show_relname, ExplainState *es)
void ExplainQueryParameters(ExplainState *es, ParamListInfo params, int maxlen)
static void ExplainPrintSerialize(ExplainState *es, SerializeMetrics *metrics)
static void show_grouping_sets(PlanState *planstate, Agg *agg, List *ancestors, ExplainState *es)
static void ExplainPrintSettings(ExplainState *es)
static void ExplainCloseWorker(int n, ExplainState *es)
static void ExplainOpenWorker(int n, ExplainState *es)
static void ExplainOneQuery(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, ParseState *pstate, ParamListInfo params)
static void ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
void ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es, ParseState *pstate, ParamListInfo params)
static void show_wal_usage(ExplainState *es, const WalUsage *usage)
static void show_storage_info(char *maxStorageType, int64 maxSpaceUsed, ExplainState *es)
static void show_grouping_set_keys(PlanState *planstate, Agg *aggnode, Sort *sortnode, List *context, bool useprefix, List *ancestors, ExplainState *es)
static void show_qual(List *qual, const char *qlabel, PlanState *planstate, List *ancestors, bool useprefix, ExplainState *es)
static void show_material_info(MaterialState *mstate, ExplainState *es)
static void show_sort_keys(SortState *sortstate, List *ancestors, ExplainState *es)
static ExplainWorkersState * ExplainCreateWorkersState(int num_workers)
void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc)
void standard_ExplainOneQuery(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
static void show_buffer_usage(ExplainState *es, const BufferUsage *usage)
static void show_incremental_sort_keys(IncrementalSortState *incrsortstate, List *ancestors, ExplainState *es)
static void ExplainCustomChildren(CustomScanState *css, List *ancestors, ExplainState *es)
const char *(* explain_get_index_name_hook_type)(Oid indexId)
void(* explain_per_plan_hook_type)(PlannedStmt *plannedstmt, IntoClause *into, struct ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
void(* ExplainOneQuery_hook_type)(Query *query, int cursorOptions, IntoClause *into, struct ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
void(* explain_per_node_hook_type)(PlanState *planstate, List *ancestors, const char *relationship, const char *plan_name, struct ExplainState *es)
SerializeMetrics GetSerializationMetrics(DestReceiver *dest)
DestReceiver * CreateExplainSerializeDestReceiver(ExplainState *es)
ExplainState * NewExplainState(void)
void ParseExplainOptionList(ExplainState *es, List *options, ParseState *pstate)
@ EXPLAIN_SERIALIZE_BINARY
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
struct config_generic ** get_explain_guc_options(int *num)
Assert(PointerIsAligned(start, uint64))
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_ADD(x, y)
#define INSTR_TIME_IS_ZERO(t)
#define INSTR_TIME_GET_DOUBLE(t)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_GET_MILLISEC(t)
#define INSTR_TIME_SET_ZERO(t)
void InstrEndLoop(Instrumentation *instr)
BufferUsage pgBufferUsage
void BufferUsageAccumDiff(BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub)
if(TABLE==NULL||TABLE_index==NULL)
void InstrJitAgg(JitInstrumentation *dst, JitInstrumentation *add)
List * lappend(List *list, void *datum)
List * list_delete_first(List *list)
List * lcons(void *datum, List *list)
char * get_rel_name(Oid relid)
char * get_opname(Oid opno)
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
Oid get_rel_namespace(Oid relid)
Oid get_typcollation(Oid typid)
char * get_collation_name(Oid colloid)
char * get_namespace_name_or_temp(Oid nspid)
char * get_constraint_name(Oid conoid)
char * get_func_name(Oid funcid)
Oid get_func_namespace(Oid funcid)
Expr * make_orclause(List *orclauses)
Expr * make_ands_explicit(List *andclauses)
Expr * make_andclause(List *andclauses)
void MemoryContextMemConsumed(MemoryContext context, MemoryContextCounters *consumed)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
Oid exprType(const Node *expr)
#define planstate_tree_walker(ps, w, c)
#define DO_AGGSPLIT_SKIPFINAL(as)
#define IsA(nodeptr, _type_)
#define DO_AGGSPLIT_COMBINE(as)
#define castNode(_type_, nodeptr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
char * BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
#define CURSOR_OPT_PARALLEL_OK
#define FRAMEOPTION_NONDEFAULT
post_parse_analyze_hook_type post_parse_analyze_hook
#define rt_fetch(rangetable_index, rangetable)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define foreach_current_index(var_or_cell)
static void * list_nth(const List *list, int n)
static ListCell * lnext(const List *l, const ListCell *c)
PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
void FreeQueryDesc(QueryDesc *qdesc)
QueryDesc * CreateQueryDesc(PlannedStmt *plannedstmt, CachedPlan *cplan, const char *sourceText, Snapshot snapshot, Snapshot crosscheck_snapshot, DestReceiver *dest, ParamListInfo params, QueryEnvironment *queryEnv, int instrument_options)
char * psprintf(const char *fmt,...)
@ COMPUTE_QUERY_ID_REGRESS
static bool IsQueryIdEnabled(void)
JumbleState * JumbleQuery(Query *query)
static const struct fns functions
#define RelationGetRelationName(relation)
List * QueryRewrite(Query *parsetree)
List * deparse_context_for_plan_tree(PlannedStmt *pstmt, List *rtable_names)
List * set_deparse_context_plan(List *dpcontext, Plan *plan, List *ancestors)
const char * quote_identifier(const char *ident)
List * select_rtable_names_for_explain(List *rtable, Bitmapset *rels_used)
char * get_window_frame_options_for_explain(int frameOptions, Node *startOffset, Node *endOffset, List *dpcontext, bool forceprefix)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
#define ScanDirectionIsBackward(direction)
@ NoMovementScanDirection
void UpdateActiveSnapshotCommandId(void)
void PopActiveSnapshot(void)
void PushCopiedSnapshot(Snapshot snapshot)
Snapshot GetActiveSnapshot(void)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoSpaces(StringInfo str, int count)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
int hash_planned_partitions
SharedAggInfo * shared_info
ParallelBitmapHeapState * pstate
BitmapHeapScanInstrumentation stats
SharedBitmapHeapInstrumentation * sinstrument
SharedIndexScanInstrumentation * biss_SharedInfo
IndexScanInstrumentation biss_Instrument
Tuplestorestate * cte_table
struct CteScanState * leader
void(* ExplainCustomScan)(CustomScanState *node, List *ancestors, ExplainState *es)
const struct CustomExecMethods * methods
List * es_tuple_routing_result_relations
struct JitContext * es_jit
struct JitInstrumentation * es_jit_worker_instr
Bitmapset * es_unpruned_relids
List * es_trig_target_relations
List * es_opened_result_relations
Bitmapset * printed_subplans
ExplainWorkersState * workers_state
ExplainSerializeOption serialize
ExplainForeignScan_function ExplainForeignScan
ExplainForeignModify_function ExplainForeignModify
ExplainDirectModify_function ExplainDirectModify
struct FdwRoutine * fdwroutine
SharedHashInfo * shared_info
HashInstrumentation * hinstrument
int64 totalMemorySpaceUsed
IncrementalSortGroupInfo prefixsortGroupInfo
IncrementalSortGroupInfo fullsortGroupInfo
SharedIncrementalSortInfo * shared_info
IncrementalSortInfo incsort_info
SharedIndexScanInstrumentation * ioss_SharedInfo
IndexScanInstrumentation ioss_Instrument
ScanDirection indexorderdir
IndexScanInstrumentation iss_Instrument
SharedIndexScanInstrumentation * iss_SharedInfo
ScanDirection indexorderdir
instr_time generation_counter
instr_time optimization_counter
instr_time deform_counter
instr_time emission_counter
instr_time inlining_counter
Tuplestorestate * tuplestorestate
SharedMemoizeInfo * shared_info
MemoizeInstrumentation stats
ResultRelInfo * resultRelInfo
OnConflictAction onConflictAction
QueryEnvironment * p_queryEnv
const char * p_sourcetext
struct SharedJitInstrumentation * worker_jit_instrument
Instrumentation * instrument
WorkerInstrumentation * worker_instrument
PlannedStmt * plannedstmt
Tuplestorestate * working_table
Tuplestorestate * intermediate_table
Instrumentation * ri_TrigInstrument
TriggerDesc * ri_TrigDesc
struct FdwRoutine * ri_FdwRoutine
bool ri_usesFdwDirectModify
AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
BitmapHeapScanInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER]
IncrementalSortInfo sinfo[FLEXIBLE_ARRAY_MEMBER]
IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER]
JitInstrumentation jit_instr[FLEXIBLE_ARRAY_MEMBER]
MemoizeInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
SharedSortInfo * shared_info
struct PlanState * planstate
Tuplestorestate * tupstore
TuplesortMethod sortMethod
TuplesortSpaceType spaceType
Instrumentation instrument[FLEXIBLE_ARRAY_MEMBER]
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
void tuplesort_get_stats(Tuplesortstate *state, TuplesortInstrumentation *stats)
const char * tuplesort_space_type_name(TuplesortSpaceType t)
const char * tuplesort_method_name(TuplesortMethod m)
#define NUM_TUPLESORTMETHODS
@ SORT_TYPE_STILL_IN_PROGRESS
void tuplestore_get_stats(Tuplestorestate *state, char **max_storage_type, int64 *max_space)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
static void usage(const char *progname)
Datum bit(PG_FUNCTION_ARGS)
void CommandCounterIncrement(void)