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",
373 &planduration, (es->
buffers ? &bufusage : NULL),
374 es->
memory ? &mem_counters : NULL);
393 if (utilityStmt == NULL)
418 elog(
ERROR,
"unexpected object type: %d",
427 (*post_parse_analyze_hook) (pstate, ctas_query, jstate);
453 (*post_parse_analyze_hook) (pstate, dcs_query, jstate);
475 "Utility statements have no plan structure\n");
503 double totaltime = 0;
505 int instrument_option = 0;
552 dest, params, queryEnv, instrument_option);
624 if (es->
summary && planduration)
650 (*explain_per_plan_hook) (plannedstmt, into, es, queryString,
705 for (
int i = 0;
i < num;
i++)
727 for (
int i = 0;
i < num;
i++)
852 routerels !=
NIL || targrels !=
NIL);
853 foreach(l, resultrels)
859 foreach(l, routerels)
934 "Inlining", jit_flags &
PGJIT_INLINE ?
"true" :
"false",
935 "Optimization", jit_flags &
PGJIT_OPT3 ?
"true" :
"false",
936 "Expressions", jit_flags &
PGJIT_EXPR ?
"true" :
"false",
937 "Deforming", jit_flags &
PGJIT_DEFORM ?
"true" :
"false");
943 "Timing: %s %.3f ms (%s %.3f ms), %s %.3f ms, %s %.3f ms, %s %.3f ms, %s %.3f ms\n",
1083 if (params == NULL || params->
numParams <= 0 || maxlen == 0)
1087 if (
str &&
str[0] !=
'\0')
1107 char *conname = NULL;
1132 if (es->
verbose || conname == NULL)
1195 case T_IndexOnlyScan:
1196 case T_BitmapHeapScan:
1198 case T_TidRangeScan:
1199 case T_SubqueryScan:
1200 case T_FunctionScan:
1201 case T_TableFuncScan:
1204 case T_NamedTuplestoreScan:
1205 case T_WorkTableScan:
1224 if (
plan->targetlist)
1252 int child_disabled_nodes;
1255 if (
plan->disabled_nodes == 0)
1258 child_disabled_nodes = 0;
1327 if (
plan->disabled_nodes > child_disabled_nodes)
1356 const char *relationship,
const char *plan_name,
1362 const char *strategy = NULL;
1363 const char *partialmode = NULL;
1364 const char *operation = NULL;
1365 const char *custom_name = NULL;
1367 int save_indent = es->
indent;
1384 pname = sname =
"Result";
1387 pname = sname =
"ProjectSet";
1390 sname =
"ModifyTable";
1394 pname = operation =
"Insert";
1397 pname = operation =
"Update";
1400 pname = operation =
"Delete";
1403 pname = operation =
"Merge";
1411 pname = sname =
"Append";
1414 pname = sname =
"Merge Append";
1416 case T_RecursiveUnion:
1417 pname = sname =
"Recursive Union";
1420 pname = sname =
"BitmapAnd";
1423 pname = sname =
"BitmapOr";
1426 pname = sname =
"Nested Loop";
1430 sname =
"Merge Join";
1434 sname =
"Hash Join";
1437 pname = sname =
"Seq Scan";
1440 pname = sname =
"Sample Scan";
1443 pname = sname =
"Gather";
1446 pname = sname =
"Gather Merge";
1449 pname = sname =
"Index Scan";
1451 case T_IndexOnlyScan:
1452 pname = sname =
"Index Only Scan";
1454 case T_BitmapIndexScan:
1455 pname = sname =
"Bitmap Index Scan";
1457 case T_BitmapHeapScan:
1458 pname = sname =
"Bitmap Heap Scan";
1461 pname = sname =
"Tid Scan";
1463 case T_TidRangeScan:
1464 pname = sname =
"Tid Range Scan";
1466 case T_SubqueryScan:
1467 pname = sname =
"Subquery Scan";
1469 case T_FunctionScan:
1470 pname = sname =
"Function Scan";
1472 case T_TableFuncScan:
1473 pname = sname =
"Table Function Scan";
1476 pname = sname =
"Values Scan";
1479 pname = sname =
"CTE Scan";
1481 case T_NamedTuplestoreScan:
1482 pname = sname =
"Named Tuplestore Scan";
1484 case T_WorkTableScan:
1485 pname = sname =
"WorkTable Scan";
1488 sname =
"Foreign Scan";
1492 pname =
"Foreign Scan";
1493 operation =
"Select";
1496 pname =
"Foreign Insert";
1497 operation =
"Insert";
1500 pname =
"Foreign Update";
1501 operation =
"Update";
1504 pname =
"Foreign Delete";
1505 operation =
"Delete";
1513 sname =
"Custom Scan";
1516 pname =
psprintf(
"Custom Scan (%s)", custom_name);
1521 pname = sname =
"Materialize";
1524 pname = sname =
"Memoize";
1527 pname = sname =
"Sort";
1529 case T_IncrementalSort:
1530 pname = sname =
"Incremental Sort";
1533 pname = sname =
"Group";
1539 sname =
"Aggregate";
1543 pname =
"Aggregate";
1547 pname =
"GroupAggregate";
1548 strategy =
"Sorted";
1551 pname =
"HashAggregate";
1552 strategy =
"Hashed";
1555 pname =
"MixedAggregate";
1559 pname =
"Aggregate ???";
1566 partialmode =
"Partial";
1567 pname =
psprintf(
"%s %s", partialmode, pname);
1571 partialmode =
"Finalize";
1572 pname =
psprintf(
"%s %s", partialmode, pname);
1575 partialmode =
"Simple";
1579 pname = sname =
"WindowAgg";
1582 pname = sname =
"Unique";
1590 strategy =
"Sorted";
1593 pname =
"HashSetOp";
1594 strategy =
"Hashed";
1597 pname =
"SetOp ???";
1603 pname = sname =
"LockRows";
1606 pname = sname =
"Limit";
1609 pname = sname =
"Hash";
1612 pname = sname =
"???";
1617 relationship ? NULL :
"Plan",
1634 if (
plan->parallel_aware)
1636 if (
plan->async_capable)
1664 case T_BitmapHeapScan:
1666 case T_TidRangeScan:
1667 case T_SubqueryScan:
1668 case T_FunctionScan:
1669 case T_TableFuncScan:
1672 case T_WorkTableScan:
1677 if (((
Scan *)
plan)->scanrelid > 0)
1690 case T_IndexOnlyScan:
1700 case T_BitmapIndexScan:
1703 const char *indexname =
1720 const char *jointype;
1743 jointype =
"Right Semi";
1746 jointype =
"Right Anti";
1769 const char *setopcmd;
1774 setopcmd =
"Intersect";
1777 setopcmd =
"Intersect All";
1780 setopcmd =
"Except";
1783 setopcmd =
"Except All";
1804 plan->startup_cost,
plan->total_cost,
1805 plan->plan_rows,
plan->plan_width);
1896 double nloops = instrument->
nloops;
1903 startup_ms = 1000.0 * instrument->
startup / nloops;
1904 total_ms = 1000.0 * instrument->
total / nloops;
1905 rows = instrument->
ntuples / nloops;
1962 "Index Cond", planstate, ancestors, es);
1967 "Order By", planstate, ancestors, es);
1974 case T_IndexOnlyScan:
1976 "Index Cond", planstate, ancestors, es);
1981 "Order By", planstate, ancestors, es);
1991 case T_BitmapIndexScan:
1993 "Index Cond", planstate, ancestors, es);
1996 case T_BitmapHeapScan:
1998 "Recheck Cond", planstate, ancestors, es);
2010 planstate, ancestors, es);
2016 case T_NamedTuplestoreScan:
2017 case T_WorkTableScan:
2018 case T_SubqueryScan:
2041 nworkers = ((
GatherState *) planstate)->nworkers_launched;
2071 case T_FunctionScan:
2085 "Function Call", planstate, ancestors,
2093 case T_TableFuncScan:
2099 "Table Function Call", planstate, ancestors,
2126 case T_TidRangeScan:
2164 "Join Filter", planstate, ancestors, es);
2175 "Merge Cond", planstate, ancestors, es);
2177 "Join Filter", planstate, ancestors, es);
2188 "Hash Cond", planstate, ancestors, es);
2190 "Join Filter", planstate, ancestors, es);
2210 "Run Condition", planstate, ancestors, es);
2228 case T_IncrementalSort:
2240 "One-Time Filter", planstate, ancestors, es);
2260 case T_RecursiveUnion:
2302 double nloops = instrument->
nloops;
2323 (*explain_per_node_hook) (planstate, ancestors, relationship,
2351 haschildren = planstate->
initPlan ||
2406 case T_SubqueryScan:
2408 "Subquery", NULL, es);
2431 es->
indent = save_indent;
2434 relationship ? NULL :
"Plan",
2483 foreach(lc,
plan->targetlist)
2551 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2565 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2577 plan->numCols, 0,
plan->sortColIdx,
2578 plan->sortOperators,
plan->collations,
2593 plan->sort.numCols,
plan->nPresortedCols,
2594 plan->sort.sortColIdx,
2595 plan->sort.sortOperators,
plan->sort.collations,
2596 plan->sort.nullsFirst,
2610 plan->numCols, 0,
plan->sortColIdx,
2611 plan->sortOperators,
plan->collations,
2630 if (
plan->groupingSets)
2659 context, useprefix, ancestors, es);
2661 foreach(lc, agg->
chain)
2667 context, useprefix, ancestors, es);
2684 const char *keyname;
2685 const char *keysetname;
2689 keyname =
"Hash Key";
2690 keysetname =
"Hash Keys";
2694 keyname =
"Group Key";
2695 keysetname =
"Group Keys";
2703 sortnode->
numCols, 0, sortnode->sortColIdx,
2704 sortnode->sortOperators, sortnode->collations,
2705 sortnode->nullsFirst,
2726 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2731 result =
lappend(result, exprstr);
2773 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
2774 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
2796 for (keyno = 0; keyno < nkeys; keyno++)
2805 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2812 if (sortOperators != NULL)
2815 sortOperators[keyno],
2820 if (keyno < nPresortedKeys)
2821 resultPresorted =
lappend(resultPresorted, exprstr);
2825 if (nPresortedKeys > 0)
2835 Oid sortOperator,
Oid collation,
bool nullsFirst)
2838 bool reverse =
false;
2855 if (collname == NULL)
2856 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2861 if (sortOperator == typentry->
gt_opr)
2866 else if (sortOperator != typentry->
lt_opr)
2871 elog(
ERROR,
"cache lookup failed for operator %u", sortOperator);
2878 if (nullsFirst && !reverse)
2882 else if (!nullsFirst && reverse)
2896 bool needspace =
false;
2902 ancestors =
lcons(wagg, ancestors);
2969 for (
int keyno = 0; keyno < nkeys; keyno++)
2978 elog(
ERROR,
"no tlist entry for key %d", keyresno);
3042 foreach(lc, tsc->
args)
3097 const char *sortMethod;
3098 const char *spaceType;
3104 spaceUsed = stats.spaceUsed;
3110 sortMethod, spaceType, spaceUsed);
3136 const char *sortMethod;
3137 const char *spaceType;
3155 sortMethod, spaceType, spaceUsed);
3209 foreach(methodCell, methodNames)
3219 const char *spaceTypeName;
3223 spaceTypeName, avgSpace,
3231 const char *spaceTypeName;
3235 spaceTypeName, avgSpace,
3253 const char *spaceTypeName;
3270 const char *spaceTypeName;
3330 bool indent_first_line;
3358 indent_first_line, es);
3426 if (hinstrument.
nbatch > 0)
3448 "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: " UINT64_FORMAT "kB\n",
3459 "Buckets: %d Batches: %d Memory Usage: " UINT64_FORMAT "kB\n",
3473 char *maxStorageType;
3482 if (!es->
analyze || tupstore == NULL)
3496 char *maxStorageType;
3505 if (!es->
analyze || tupstore == NULL)
3519 char *maxStorageType;
3524 if (!es->
analyze || tupstore == NULL)
3538 char *maxStorageType;
3543 if (!es->
analyze || tupstore == NULL)
3557 char *maxStorageType,
3575 if (tempSpaceUsed > maxSpaceUsed)
3576 maxStorageType = tempStorageType;
3578 maxSpaceUsed += tempSpaceUsed;
3751 bool gotone =
false;
3796 int hash_batches_used;
3814 hash_batches_used, memPeakKb);
3817 if (hash_batches_used > 1)
3825 hash_batches_used, es);
3862 case T_IndexOnlyScan:
3870 case T_BitmapIndexScan:
3927 if (planstate->
pstate != NULL)
4031 result = (*explain_get_index_name_hook) (indexId);
4039 elog(
ERROR,
"cache lookup failed for index %u", indexId);
4055 bool has_shared_timing;
4056 bool has_local_timing;
4057 bool has_temp_timing;
4065 has_shared = (
usage->shared_blks_hit > 0 ||
4066 usage->shared_blks_read > 0 ||
4067 usage->shared_blks_dirtied > 0 ||
4068 usage->shared_blks_written > 0);
4069 has_local = (
usage->local_blks_hit > 0 ||
4070 usage->local_blks_read > 0 ||
4071 usage->local_blks_dirtied > 0 ||
4072 usage->local_blks_written > 0);
4073 has_temp = (
usage->temp_blks_read > 0 ||
4074 usage->temp_blks_written > 0);
4082 return has_shared || has_local || has_temp || has_shared_timing ||
4083 has_local_timing || has_temp_timing;
4094 bool has_shared = (
usage->shared_blks_hit > 0 ||
4095 usage->shared_blks_read > 0 ||
4096 usage->shared_blks_dirtied > 0 ||
4097 usage->shared_blks_written > 0);
4098 bool has_local = (
usage->local_blks_hit > 0 ||
4099 usage->local_blks_read > 0 ||
4100 usage->local_blks_dirtied > 0 ||
4101 usage->local_blks_written > 0);
4102 bool has_temp = (
usage->temp_blks_read > 0 ||
4103 usage->temp_blks_written > 0);
4112 if (has_shared || has_local || has_temp)
4120 if (
usage->shared_blks_hit > 0)
4122 usage->shared_blks_hit);
4123 if (
usage->shared_blks_read > 0)
4125 usage->shared_blks_read);
4126 if (
usage->shared_blks_dirtied > 0)
4128 usage->shared_blks_dirtied);
4129 if (
usage->shared_blks_written > 0)
4131 usage->shared_blks_written);
4132 if (has_local || has_temp)
4138 if (
usage->local_blks_hit > 0)
4140 usage->local_blks_hit);
4141 if (
usage->local_blks_read > 0)
4143 usage->local_blks_read);
4144 if (
usage->local_blks_dirtied > 0)
4146 usage->local_blks_dirtied);
4147 if (
usage->local_blks_written > 0)
4149 usage->local_blks_written);
4156 if (
usage->temp_blks_read > 0)
4158 usage->temp_blks_read);
4159 if (
usage->temp_blks_written > 0)
4161 usage->temp_blks_written);
4167 if (has_shared_timing || has_local_timing || has_temp_timing)
4172 if (has_shared_timing)
4181 if (has_local_timing || has_temp_timing)
4184 if (has_local_timing)
4193 if (has_temp_timing)
4196 if (has_temp_timing)
4212 usage->shared_blks_hit, es);
4214 usage->shared_blks_read, es);
4216 usage->shared_blks_dirtied, es);
4218 usage->shared_blks_written, es);
4220 usage->local_blks_hit, es);
4222 usage->local_blks_read, es);
4224 usage->local_blks_dirtied, es);
4226 usage->local_blks_written, es);
4228 usage->temp_blks_read, es);
4230 usage->temp_blks_written, es);
4264 if ((
usage->wal_records > 0) || (
usage->wal_fpi > 0) ||
4265 (
usage->wal_bytes > 0) || (
usage->wal_buffers_full > 0))
4270 if (
usage->wal_records > 0)
4272 usage->wal_records);
4273 if (
usage->wal_fpi > 0)
4276 if (
usage->wal_bytes > 0)
4279 if (
usage->wal_buffers_full > 0)
4281 usage->wal_buffers_full);
4288 usage->wal_records, es);
4290 usage->wal_fpi, es);
4292 usage->wal_bytes, es);
4294 usage->wal_buffers_full, es);
4313 memUsedkB, memAllocatedkB);
4341 const char *scandir;
4343 switch (indexorderdir)
4346 scandir =
"Backward";
4349 scandir =
"Forward";
4388 char *objectname = NULL;
4389 char *
namespace = NULL;
4390 const char *objecttag = NULL;
4396 if (refname == NULL)
4397 refname = rte->eref->aliasname;
4404 case T_IndexOnlyScan:
4405 case T_BitmapHeapScan:
4407 case T_TidRangeScan:
4416 objecttag =
"Relation Name";
4418 case T_FunctionScan:
4445 objecttag =
"Function Name";
4448 case T_TableFuncScan:
4456 objectname =
"xmltable";
4459 objectname =
"json_table";
4462 elog(
ERROR,
"invalid TableFunc type %d",
4465 objecttag =
"Table Function Name";
4474 Assert(!rte->self_reference);
4475 objectname = rte->ctename;
4476 objecttag =
"CTE Name";
4478 case T_NamedTuplestoreScan:
4480 objectname = rte->enrname;
4481 objecttag =
"Tuplestore Name";
4483 case T_WorkTableScan:
4486 Assert(rte->self_reference);
4487 objectname = rte->ctename;
4488 objecttag =
"CTE Name";
4497 if (
namespace != NULL)
4500 else if (objectname != NULL)
4502 if (objectname == NULL || strcmp(refname, objectname) != 0)
4507 if (objecttag != NULL && objectname != NULL)
4509 if (
namespace != NULL)
4528 const char *operation;
4529 const char *foperation;
4538 operation =
"Insert";
4539 foperation =
"Foreign Insert";
4542 operation =
"Update";
4543 foperation =
"Foreign Update";
4546 operation =
"Delete";
4547 foperation =
"Foreign Delete";
4550 operation =
"Merge";
4552 foperation =
"Foreign Merge";
4556 foperation =
"Foreign ???";
4569 labeltargets = (mtstate->
mt_nrels > 1 ||
4596 fdwroutine ? foperation : operation);
4613 fdwroutine != NULL &&
4641 idxNames =
lappend(idxNames, indexname);
4648 "NOTHING" :
"UPDATE",
4662 &mtstate->
ps, ancestors, es);
4678 insert_path = total - other_path;
4681 insert_path, 0, es);
4695 double skipped_path;
4704 skipped_path = total - insert_path - update_path - delete_path;
4705 Assert(skipped_path >= 0);
4713 if (insert_path > 0)
4715 if (update_path > 0)
4717 if (delete_path > 0)
4719 if (skipped_path > 0)
4751 for (
j = 0;
j < nplans;
j++)
4753 "Member", NULL, es);
4768 nchildren - nplans, es);
4808 ancestors =
lcons(sp, ancestors);
4865 Assert(n >= 0 && n < wstate->num_workers);
4927 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
void ExecutorEnd(QueryDesc *queryDesc)
void ExecutorFinish(QueryDesc *queryDesc)
void ExecutorStart(QueryDesc *queryDesc, int eflags)
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)
void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, const instr_time *planduration, const BufferUsage *bufusage, const MemoryContextCounters *mem_counters)
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)
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, 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)