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);
195 (*post_parse_analyze_hook) (pstate, query, jstate);
208 if (rewritten ==
NIL)
222 foreach(l, rewritten)
229 if (
lnext(rewritten, l) != NULL)
259 Oid result_type = TEXTOID;
262 foreach(lc,
stmt->options)
266 if (strcmp(opt->
defname,
"format") == 0)
270 if (strcmp(p,
"xml") == 0)
271 result_type = XMLOID;
272 else if (strcmp(p,
"json") == 0)
273 result_type = JSONOID;
275 result_type = TEXTOID;
307 (*ExplainOneQuery_hook) (query, cursorOptions, into, es,
344 "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");
504 double totaltime = 0;
506 int instrument_option = 0;
553 dest, params, queryEnv, instrument_option);
625 if (es->
summary && planduration)
651 (*explain_per_plan_hook) (plannedstmt, into, es, queryString,
706 for (
int i = 0;
i < num;
i++)
728 for (
int i = 0;
i < num;
i++)
849 routerels !=
NIL || targrels !=
NIL);
850 foreach(l, resultrels)
856 foreach(l, routerels)
931 "Inlining", jit_flags &
PGJIT_INLINE ?
"true" :
"false",
932 "Optimization", jit_flags &
PGJIT_OPT3 ?
"true" :
"false",
933 "Expressions", jit_flags &
PGJIT_EXPR ?
"true" :
"false",
934 "Deforming", jit_flags &
PGJIT_DEFORM ?
"true" :
"false");
940 "Timing: %s %.3f ms (%s %.3f ms), %s %.3f ms, %s %.3f ms, %s %.3f ms, %s %.3f ms\n",
1080 if (params == NULL || params->
numParams <= 0 || maxlen == 0)
1084 if (
str &&
str[0] !=
'\0')
1104 char *conname = NULL;
1129 if (es->
verbose || conname == NULL)
1192 case T_IndexOnlyScan:
1193 case T_BitmapHeapScan:
1195 case T_TidRangeScan:
1196 case T_SubqueryScan:
1197 case T_FunctionScan:
1198 case T_TableFuncScan:
1201 case T_NamedTuplestoreScan:
1202 case T_WorkTableScan:
1221 if (
plan->targetlist)
1253 int child_disabled_nodes;
1256 if (
plan->disabled_nodes == 0)
1259 child_disabled_nodes = 0;
1328 if (
plan->disabled_nodes > child_disabled_nodes)
1357 const char *relationship,
const char *plan_name,
1363 const char *strategy = NULL;
1364 const char *partialmode = NULL;
1365 const char *operation = NULL;
1366 const char *custom_name = NULL;
1368 int save_indent = es->
indent;
1385 pname = sname =
"Result";
1388 pname = sname =
"ProjectSet";
1391 sname =
"ModifyTable";
1395 pname = operation =
"Insert";
1398 pname = operation =
"Update";
1401 pname = operation =
"Delete";
1404 pname = operation =
"Merge";
1412 pname = sname =
"Append";
1415 pname = sname =
"Merge Append";
1417 case T_RecursiveUnion:
1418 pname = sname =
"Recursive Union";
1421 pname = sname =
"BitmapAnd";
1424 pname = sname =
"BitmapOr";
1427 pname = sname =
"Nested Loop";
1431 sname =
"Merge Join";
1435 sname =
"Hash Join";
1438 pname = sname =
"Seq Scan";
1441 pname = sname =
"Sample Scan";
1444 pname = sname =
"Gather";
1447 pname = sname =
"Gather Merge";
1450 pname = sname =
"Index Scan";
1452 case T_IndexOnlyScan:
1453 pname = sname =
"Index Only Scan";
1455 case T_BitmapIndexScan:
1456 pname = sname =
"Bitmap Index Scan";
1458 case T_BitmapHeapScan:
1459 pname = sname =
"Bitmap Heap Scan";
1462 pname = sname =
"Tid Scan";
1464 case T_TidRangeScan:
1465 pname = sname =
"Tid Range Scan";
1467 case T_SubqueryScan:
1468 pname = sname =
"Subquery Scan";
1470 case T_FunctionScan:
1471 pname = sname =
"Function Scan";
1473 case T_TableFuncScan:
1474 pname = sname =
"Table Function Scan";
1477 pname = sname =
"Values Scan";
1480 pname = sname =
"CTE Scan";
1482 case T_NamedTuplestoreScan:
1483 pname = sname =
"Named Tuplestore Scan";
1485 case T_WorkTableScan:
1486 pname = sname =
"WorkTable Scan";
1489 sname =
"Foreign Scan";
1493 pname =
"Foreign Scan";
1494 operation =
"Select";
1497 pname =
"Foreign Insert";
1498 operation =
"Insert";
1501 pname =
"Foreign Update";
1502 operation =
"Update";
1505 pname =
"Foreign Delete";
1506 operation =
"Delete";
1514 sname =
"Custom Scan";
1517 pname =
psprintf(
"Custom Scan (%s)", custom_name);
1522 pname = sname =
"Materialize";
1525 pname = sname =
"Memoize";
1528 pname = sname =
"Sort";
1530 case T_IncrementalSort:
1531 pname = sname =
"Incremental Sort";
1534 pname = sname =
"Group";
1540 sname =
"Aggregate";
1544 pname =
"Aggregate";
1548 pname =
"GroupAggregate";
1549 strategy =
"Sorted";
1552 pname =
"HashAggregate";
1553 strategy =
"Hashed";
1556 pname =
"MixedAggregate";
1560 pname =
"Aggregate ???";
1567 partialmode =
"Partial";
1568 pname =
psprintf(
"%s %s", partialmode, pname);
1572 partialmode =
"Finalize";
1573 pname =
psprintf(
"%s %s", partialmode, pname);
1576 partialmode =
"Simple";
1580 pname = sname =
"WindowAgg";
1583 pname = sname =
"Unique";
1591 strategy =
"Sorted";
1594 pname =
"HashSetOp";
1595 strategy =
"Hashed";
1598 pname =
"SetOp ???";
1604 pname = sname =
"LockRows";
1607 pname = sname =
"Limit";
1610 pname = sname =
"Hash";
1613 pname = sname =
"???";
1618 relationship ? NULL :
"Plan",
1635 if (
plan->parallel_aware)
1637 if (
plan->async_capable)
1665 case T_BitmapHeapScan:
1667 case T_TidRangeScan:
1668 case T_SubqueryScan:
1669 case T_FunctionScan:
1670 case T_TableFuncScan:
1673 case T_WorkTableScan:
1678 if (((
Scan *)
plan)->scanrelid > 0)
1691 case T_IndexOnlyScan:
1701 case T_BitmapIndexScan:
1704 const char *indexname =
1721 const char *jointype;
1744 jointype =
"Right Semi";
1747 jointype =
"Right Anti";
1770 const char *setopcmd;
1775 setopcmd =
"Intersect";
1778 setopcmd =
"Intersect All";
1781 setopcmd =
"Except";
1784 setopcmd =
"Except All";
1805 plan->startup_cost,
plan->total_cost,
1806 plan->plan_rows,
plan->plan_width);
1897 double nloops = instrument->
nloops;
1904 startup_ms = 1000.0 * instrument->
startup / nloops;
1905 total_ms = 1000.0 * instrument->
total / nloops;
1906 rows = instrument->
ntuples / nloops;
1963 "Index Cond", planstate, ancestors, es);
1968 "Order By", planstate, ancestors, es);
1975 case T_IndexOnlyScan:
1977 "Index Cond", planstate, ancestors, es);
1982 "Order By", planstate, ancestors, es);
1992 case T_BitmapIndexScan:
1994 "Index Cond", planstate, ancestors, es);
1997 case T_BitmapHeapScan:
1999 "Recheck Cond", planstate, ancestors, es);
2011 planstate, ancestors, es);
2017 case T_NamedTuplestoreScan:
2018 case T_WorkTableScan:
2019 case T_SubqueryScan:
2042 nworkers = ((
GatherState *) planstate)->nworkers_launched;
2072 case T_FunctionScan:
2086 "Function Call", planstate, ancestors,
2094 case T_TableFuncScan:
2100 "Table Function Call", planstate, ancestors,
2127 case T_TidRangeScan:
2165 "Join Filter", planstate, ancestors, es);
2176 "Merge Cond", planstate, ancestors, es);
2178 "Join Filter", planstate, ancestors, es);
2189 "Hash Cond", planstate, ancestors, es);
2191 "Join Filter", planstate, ancestors, es);
2211 "Run Condition", planstate, ancestors, es);
2229 case T_IncrementalSort:
2242 "One-Time Filter", planstate, ancestors, es);
2262 case T_RecursiveUnion:
2304 double nloops = instrument->
nloops;
2325 (*explain_per_node_hook) (planstate, ancestors, relationship,
2353 haschildren = planstate->
initPlan ||
2408 case T_SubqueryScan:
2410 "Subquery", NULL, es);
2433 es->
indent = save_indent;
2436 relationship ? NULL :
"Plan",
2485 foreach(lc,
plan->targetlist)
2553 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2567 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2579 plan->numCols, 0,
plan->sortColIdx,
2580 plan->sortOperators,
plan->collations,
2595 plan->sort.numCols,
plan->nPresortedCols,
2596 plan->sort.sortColIdx,
2597 plan->sort.sortOperators,
plan->sort.collations,
2598 plan->sort.nullsFirst,
2612 plan->numCols, 0,
plan->sortColIdx,
2613 plan->sortOperators,
plan->collations,
2632 if (
plan->groupingSets)
2661 context, useprefix, ancestors, es);
2663 foreach(lc, agg->
chain)
2669 context, useprefix, ancestors, es);
2686 const char *keyname;
2687 const char *keysetname;
2691 keyname =
"Hash Key";
2692 keysetname =
"Hash Keys";
2696 keyname =
"Group Key";
2697 keysetname =
"Group Keys";
2705 sortnode->
numCols, 0, sortnode->sortColIdx,
2706 sortnode->sortOperators, sortnode->collations,
2707 sortnode->nullsFirst,
2728 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2733 result =
lappend(result, exprstr);
2775 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
2776 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
2798 for (keyno = 0; keyno < nkeys; keyno++)
2807 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2814 if (sortOperators != NULL)
2817 sortOperators[keyno],
2822 if (keyno < nPresortedKeys)
2823 resultPresorted =
lappend(resultPresorted, exprstr);
2827 if (nPresortedKeys > 0)
2837 Oid sortOperator,
Oid collation,
bool nullsFirst)
2840 bool reverse =
false;
2857 if (collname == NULL)
2858 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2863 if (sortOperator == typentry->
gt_opr)
2868 else if (sortOperator != typentry->
lt_opr)
2873 elog(
ERROR,
"cache lookup failed for operator %u", sortOperator);
2880 if (nullsFirst && !reverse)
2884 else if (!nullsFirst && reverse)
2898 bool needspace =
false;
2904 ancestors =
lcons(wagg, ancestors);
2971 for (
int keyno = 0; keyno < nkeys; keyno++)
2980 elog(
ERROR,
"no tlist entry for key %d", keyresno);
3044 foreach(lc, tsc->
args)
3099 const char *sortMethod;
3100 const char *spaceType;
3106 spaceUsed = stats.spaceUsed;
3112 sortMethod, spaceType, spaceUsed);
3138 const char *sortMethod;
3139 const char *spaceType;
3157 sortMethod, spaceType, spaceUsed);
3211 foreach(methodCell, methodNames)
3221 const char *spaceTypeName;
3225 spaceTypeName, avgSpace,
3233 const char *spaceTypeName;
3237 spaceTypeName, avgSpace,
3255 const char *spaceTypeName;
3272 const char *spaceTypeName;
3332 bool indent_first_line;
3360 indent_first_line, es);
3428 if (hinstrument.
nbatch > 0)
3450 "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: " UINT64_FORMAT "kB\n",
3461 "Buckets: %d Batches: %d Memory Usage: " UINT64_FORMAT "kB\n",
3475 char *maxStorageType;
3484 if (!es->
analyze || tupstore == NULL)
3498 char *maxStorageType;
3507 if (!es->
analyze || tupstore == NULL)
3521 char *maxStorageType;
3526 if (!es->
analyze || tupstore == NULL)
3540 char *maxStorageType;
3545 if (!es->
analyze || tupstore == NULL)
3559 char *maxStorageType,
3577 if (tempSpaceUsed > maxSpaceUsed)
3578 maxStorageType = tempStorageType;
3580 maxSpaceUsed += tempSpaceUsed;
3633 appendStringInfo(es->
str,
"Estimates: capacity=%u distinct keys=%.0f lookups=%.0f hit percent=%.2f%%\n",
3772 bool gotone =
false;
3817 int hash_batches_used;
3835 hash_batches_used, memPeakKb);
3838 if (hash_batches_used > 1)
3846 hash_batches_used, es);
3883 case T_IndexOnlyScan:
3891 case T_BitmapIndexScan:
3948 if (planstate->
pstate != NULL)
4052 result = (*explain_get_index_name_hook) (indexId);
4060 elog(
ERROR,
"cache lookup failed for index %u", indexId);
4076 bool has_shared_timing;
4077 bool has_local_timing;
4078 bool has_temp_timing;
4086 has_shared = (
usage->shared_blks_hit > 0 ||
4087 usage->shared_blks_read > 0 ||
4088 usage->shared_blks_dirtied > 0 ||
4089 usage->shared_blks_written > 0);
4090 has_local = (
usage->local_blks_hit > 0 ||
4091 usage->local_blks_read > 0 ||
4092 usage->local_blks_dirtied > 0 ||
4093 usage->local_blks_written > 0);
4094 has_temp = (
usage->temp_blks_read > 0 ||
4095 usage->temp_blks_written > 0);
4103 return has_shared || has_local || has_temp || has_shared_timing ||
4104 has_local_timing || has_temp_timing;
4115 bool has_shared = (
usage->shared_blks_hit > 0 ||
4116 usage->shared_blks_read > 0 ||
4117 usage->shared_blks_dirtied > 0 ||
4118 usage->shared_blks_written > 0);
4119 bool has_local = (
usage->local_blks_hit > 0 ||
4120 usage->local_blks_read > 0 ||
4121 usage->local_blks_dirtied > 0 ||
4122 usage->local_blks_written > 0);
4123 bool has_temp = (
usage->temp_blks_read > 0 ||
4124 usage->temp_blks_written > 0);
4133 if (has_shared || has_local || has_temp)
4141 if (
usage->shared_blks_hit > 0)
4143 usage->shared_blks_hit);
4144 if (
usage->shared_blks_read > 0)
4146 usage->shared_blks_read);
4147 if (
usage->shared_blks_dirtied > 0)
4149 usage->shared_blks_dirtied);
4150 if (
usage->shared_blks_written > 0)
4152 usage->shared_blks_written);
4153 if (has_local || has_temp)
4159 if (
usage->local_blks_hit > 0)
4161 usage->local_blks_hit);
4162 if (
usage->local_blks_read > 0)
4164 usage->local_blks_read);
4165 if (
usage->local_blks_dirtied > 0)
4167 usage->local_blks_dirtied);
4168 if (
usage->local_blks_written > 0)
4170 usage->local_blks_written);
4177 if (
usage->temp_blks_read > 0)
4179 usage->temp_blks_read);
4180 if (
usage->temp_blks_written > 0)
4182 usage->temp_blks_written);
4188 if (has_shared_timing || has_local_timing || has_temp_timing)
4193 if (has_shared_timing)
4202 if (has_local_timing || has_temp_timing)
4205 if (has_local_timing)
4214 if (has_temp_timing)
4217 if (has_temp_timing)
4233 usage->shared_blks_hit, es);
4235 usage->shared_blks_read, es);
4237 usage->shared_blks_dirtied, es);
4239 usage->shared_blks_written, es);
4241 usage->local_blks_hit, es);
4243 usage->local_blks_read, es);
4245 usage->local_blks_dirtied, es);
4247 usage->local_blks_written, es);
4249 usage->temp_blks_read, es);
4251 usage->temp_blks_written, es);
4285 if ((
usage->wal_records > 0) || (
usage->wal_fpi > 0) ||
4286 (
usage->wal_bytes > 0) || (
usage->wal_buffers_full > 0))
4291 if (
usage->wal_records > 0)
4293 usage->wal_records);
4294 if (
usage->wal_fpi > 0)
4297 if (
usage->wal_bytes > 0)
4300 if (
usage->wal_buffers_full > 0)
4302 usage->wal_buffers_full);
4309 usage->wal_records, es);
4311 usage->wal_fpi, es);
4313 usage->wal_bytes, es);
4315 usage->wal_buffers_full, es);
4334 memUsedkB, memAllocatedkB);
4362 const char *scandir;
4364 switch (indexorderdir)
4367 scandir =
"Backward";
4370 scandir =
"Forward";
4409 char *objectname = NULL;
4410 char *
namespace = NULL;
4411 const char *objecttag = NULL;
4417 if (refname == NULL)
4418 refname = rte->eref->aliasname;
4425 case T_IndexOnlyScan:
4426 case T_BitmapHeapScan:
4428 case T_TidRangeScan:
4437 objecttag =
"Relation Name";
4439 case T_FunctionScan:
4466 objecttag =
"Function Name";
4469 case T_TableFuncScan:
4477 objectname =
"xmltable";
4480 objectname =
"json_table";
4483 elog(
ERROR,
"invalid TableFunc type %d",
4486 objecttag =
"Table Function Name";
4495 Assert(!rte->self_reference);
4496 objectname = rte->ctename;
4497 objecttag =
"CTE Name";
4499 case T_NamedTuplestoreScan:
4501 objectname = rte->enrname;
4502 objecttag =
"Tuplestore Name";
4504 case T_WorkTableScan:
4507 Assert(rte->self_reference);
4508 objectname = rte->ctename;
4509 objecttag =
"CTE Name";
4518 if (
namespace != NULL)
4521 else if (objectname != NULL)
4523 if (objectname == NULL || strcmp(refname, objectname) != 0)
4528 if (objecttag != NULL && objectname != NULL)
4530 if (
namespace != NULL)
4549 const char *operation;
4550 const char *foperation;
4559 operation =
"Insert";
4560 foperation =
"Foreign Insert";
4563 operation =
"Update";
4564 foperation =
"Foreign Update";
4567 operation =
"Delete";
4568 foperation =
"Foreign Delete";
4571 operation =
"Merge";
4573 foperation =
"Foreign Merge";
4577 foperation =
"Foreign ???";
4590 labeltargets = (mtstate->
mt_nrels > 1 ||
4617 fdwroutine ? foperation : operation);
4634 fdwroutine != NULL &&
4662 idxNames =
lappend(idxNames, indexname);
4669 "NOTHING" :
"UPDATE",
4683 &mtstate->
ps, ancestors, es);
4699 insert_path = total - other_path;
4702 insert_path, 0, es);
4716 double skipped_path;
4725 skipped_path = total - insert_path - update_path - delete_path;
4726 Assert(skipped_path >= 0);
4734 if (insert_path > 0)
4736 if (update_path > 0)
4738 if (delete_path > 0)
4740 if (skipped_path > 0)
4768 bool found_non_result =
false;
4769 char *replacement_type =
"???";
4781 replacement_type =
"Gating";
4784 replacement_type =
"Scan";
4787 replacement_type =
"Join";
4791 replacement_type =
"Aggregate";
4794 replacement_type =
"MinMaxAggregate";
4823 if (refname == NULL)
4824 refname = rte->eref->aliasname;
4831 found_non_result =
true;
4840 if (nrels <= 1 && !found_non_result &&
4849 char *s =
psprintf(
"%s on %s", replacement_type,
buf.data);
4868 for (
j = 0;
j < nplans;
j++)
4870 "Member", NULL, es);
4885 nchildren - nplans, es);
4925 ancestors =
lcons(sp, ancestors);
4982 Assert(n >= 0 && n < wstate->num_workers);
5044 Assert(n >= 0 && n < wstate->num_workers);
void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es, ParseState *pstate, ParamListInfo params)
int bms_next_member(const Bitmapset *a, int prevbit)
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_result_replacement_info(Result *result, 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, 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, ExplainState *es)
void(* ExplainOneQuery_hook_type)(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
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
Cardinality est_unique_keys
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
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)