62 #define X_CLOSE_IMMEDIATE 2
63 #define X_NOWHITESPACE 4
78 const char *relationship,
const char *plan_name,
111 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
112 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
115 Oid sortOperator,
Oid collation,
bool nullsFirst);
185 bool timing_set =
false;
186 bool summary_set =
false;
189 foreach(lc,
stmt->options)
193 if (strcmp(opt->
defname,
"analyze") == 0)
195 else if (strcmp(opt->
defname,
"verbose") == 0)
197 else if (strcmp(opt->
defname,
"costs") == 0)
199 else if (strcmp(opt->
defname,
"buffers") == 0)
201 else if (strcmp(opt->
defname,
"wal") == 0)
203 else if (strcmp(opt->
defname,
"settings") == 0)
205 else if (strcmp(opt->
defname,
"generic_plan") == 0)
207 else if (strcmp(opt->
defname,
"timing") == 0)
212 else if (strcmp(opt->
defname,
"summary") == 0)
217 else if (strcmp(opt->
defname,
"memory") == 0)
219 else if (strcmp(opt->
defname,
"serialize") == 0)
225 if (strcmp(p,
"off") == 0 || strcmp(p,
"none") == 0)
227 else if (strcmp(p,
"text") == 0)
229 else if (strcmp(p,
"binary") == 0)
233 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
234 errmsg(
"unrecognized value for EXPLAIN option \"%s\": \"%s\"",
244 else if (strcmp(opt->
defname,
"format") == 0)
248 if (strcmp(p,
"text") == 0)
250 else if (strcmp(p,
"xml") == 0)
252 else if (strcmp(p,
"json") == 0)
254 else if (strcmp(p,
"yaml") == 0)
258 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
259 errmsg(
"unrecognized value for EXPLAIN option \"%s\": \"%s\"",
265 (
errcode(ERRCODE_SYNTAX_ERROR),
266 errmsg(
"unrecognized EXPLAIN option \"%s\"",
274 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
275 errmsg(
"EXPLAIN option WAL requires ANALYZE")));
283 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
284 errmsg(
"EXPLAIN option TIMING requires ANALYZE")));
289 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
290 errmsg(
"EXPLAIN option SERIALIZE requires ANALYZE")));
295 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
296 errmsg(
"EXPLAIN options ANALYZE and GENERIC_PLAN cannot be used together")));
306 (*post_parse_analyze_hook) (pstate, query, jstate);
319 if (rewritten ==
NIL)
333 foreach(l, rewritten)
340 if (
lnext(rewritten, l) != NULL)
386 Oid result_type = TEXTOID;
389 foreach(lc,
stmt->options)
393 if (strcmp(opt->
defname,
"format") == 0)
397 if (strcmp(p,
"xml") == 0)
398 result_type = XMLOID;
399 else if (strcmp(p,
"json") == 0)
400 result_type = JSONOID;
402 result_type = TEXTOID;
436 (*ExplainOneQuery_hook) (query, cursorOptions, into, es,
437 queryString, params, queryEnv);
440 queryString, params, queryEnv);
473 "explain analyze planner context",
503 &planduration, (es->
buffers ? &bufusage : NULL),
504 es->
memory ? &mem_counters : NULL);
524 if (utilityStmt == NULL)
547 elog(
ERROR,
"unexpected object type: %d",
556 queryString, params, queryEnv);
575 queryString, params, queryEnv);
579 queryString, params, queryEnv);
591 "Utility statements have no plan structure\n");
619 double totaltime = 0;
621 int instrument_option = 0;
668 dest, params, queryEnv, instrument_option);
740 if (es->
summary && planduration)
816 for (
int i = 0;
i < num;
i++)
838 for (
int i = 0;
i < num;
i++)
951 routerels !=
NIL || targrels !=
NIL);
952 foreach(l, resultrels)
958 foreach(l, routerels)
1033 "Inlining", jit_flags &
PGJIT_INLINE ?
"true" :
"false",
1034 "Optimization", jit_flags &
PGJIT_OPT3 ?
"true" :
"false",
1035 "Expressions", jit_flags &
PGJIT_EXPR ?
"true" :
"false",
1036 "Deforming", jit_flags &
PGJIT_DEFORM ?
"true" :
"false");
1042 "Timing: %s %.3f ms (%s %.3f ms), %s %.3f ms, %s %.3f ms, %s %.3f ms, %s %.3f ms\n",
1182 if (params == NULL || params->
numParams <= 0 || maxlen == 0)
1186 if (
str &&
str[0] !=
'\0')
1206 char *conname = NULL;
1231 if (es->
verbose || conname == NULL)
1294 case T_IndexOnlyScan:
1295 case T_BitmapHeapScan:
1297 case T_TidRangeScan:
1298 case T_SubqueryScan:
1299 case T_FunctionScan:
1300 case T_TableFuncScan:
1303 case T_NamedTuplestoreScan:
1304 case T_WorkTableScan:
1361 const char *relationship,
const char *plan_name,
1367 const char *strategy = NULL;
1368 const char *partialmode = NULL;
1369 const char *operation = NULL;
1370 const char *custom_name = NULL;
1372 int save_indent = es->
indent;
1388 pname = sname =
"Result";
1391 pname = sname =
"ProjectSet";
1394 sname =
"ModifyTable";
1398 pname = operation =
"Insert";
1401 pname = operation =
"Update";
1404 pname = operation =
"Delete";
1407 pname = operation =
"Merge";
1415 pname = sname =
"Append";
1418 pname = sname =
"Merge Append";
1420 case T_RecursiveUnion:
1421 pname = sname =
"Recursive Union";
1424 pname = sname =
"BitmapAnd";
1427 pname = sname =
"BitmapOr";
1430 pname = sname =
"Nested Loop";
1434 sname =
"Merge Join";
1438 sname =
"Hash Join";
1441 pname = sname =
"Seq Scan";
1444 pname = sname =
"Sample Scan";
1447 pname = sname =
"Gather";
1450 pname = sname =
"Gather Merge";
1453 pname = sname =
"Index Scan";
1455 case T_IndexOnlyScan:
1456 pname = sname =
"Index Only Scan";
1458 case T_BitmapIndexScan:
1459 pname = sname =
"Bitmap Index Scan";
1461 case T_BitmapHeapScan:
1462 pname = sname =
"Bitmap Heap Scan";
1465 pname = sname =
"Tid Scan";
1467 case T_TidRangeScan:
1468 pname = sname =
"Tid Range Scan";
1470 case T_SubqueryScan:
1471 pname = sname =
"Subquery Scan";
1473 case T_FunctionScan:
1474 pname = sname =
"Function Scan";
1476 case T_TableFuncScan:
1477 pname = sname =
"Table Function Scan";
1480 pname = sname =
"Values Scan";
1483 pname = sname =
"CTE Scan";
1485 case T_NamedTuplestoreScan:
1486 pname = sname =
"Named Tuplestore Scan";
1488 case T_WorkTableScan:
1489 pname = sname =
"WorkTable Scan";
1492 sname =
"Foreign Scan";
1496 pname =
"Foreign Scan";
1497 operation =
"Select";
1500 pname =
"Foreign Insert";
1501 operation =
"Insert";
1504 pname =
"Foreign Update";
1505 operation =
"Update";
1508 pname =
"Foreign Delete";
1509 operation =
"Delete";
1517 sname =
"Custom Scan";
1520 pname =
psprintf(
"Custom Scan (%s)", custom_name);
1525 pname = sname =
"Materialize";
1528 pname = sname =
"Memoize";
1531 pname = sname =
"Sort";
1533 case T_IncrementalSort:
1534 pname = sname =
"Incremental Sort";
1537 pname = sname =
"Group";
1543 sname =
"Aggregate";
1547 pname =
"Aggregate";
1551 pname =
"GroupAggregate";
1552 strategy =
"Sorted";
1555 pname =
"HashAggregate";
1556 strategy =
"Hashed";
1559 pname =
"MixedAggregate";
1563 pname =
"Aggregate ???";
1570 partialmode =
"Partial";
1571 pname =
psprintf(
"%s %s", partialmode, pname);
1575 partialmode =
"Finalize";
1576 pname =
psprintf(
"%s %s", partialmode, pname);
1579 partialmode =
"Simple";
1583 pname = sname =
"WindowAgg";
1586 pname = sname =
"Unique";
1594 strategy =
"Sorted";
1597 pname =
"HashSetOp";
1598 strategy =
"Hashed";
1601 pname =
"SetOp ???";
1607 pname = sname =
"LockRows";
1610 pname = sname =
"Limit";
1613 pname = sname =
"Hash";
1616 pname = sname =
"???";
1621 relationship ? NULL :
"Plan",
1638 if (
plan->parallel_aware)
1640 if (
plan->async_capable)
1668 case T_BitmapHeapScan:
1670 case T_TidRangeScan:
1671 case T_SubqueryScan:
1672 case T_FunctionScan:
1673 case T_TableFuncScan:
1676 case T_WorkTableScan:
1681 if (((
Scan *)
plan)->scanrelid > 0)
1694 case T_IndexOnlyScan:
1704 case T_BitmapIndexScan:
1707 const char *indexname =
1724 const char *jointype;
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);
1846 " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)",
1847 startup_ms, total_ms, rows, nloops);
1850 " (actual rows=%.0f loops=%.0f)",
1894 double nloops = instrument->
nloops;
1901 startup_ms = 1000.0 * instrument->
startup / nloops;
1902 total_ms = 1000.0 * instrument->
total / nloops;
1903 rows = instrument->
ntuples / nloops;
1912 "actual time=%.3f..%.3f rows=%.0f loops=%.0f\n",
1913 startup_ms, total_ms, rows, nloops);
1916 "actual rows=%.0f loops=%.0f\n",
1962 "Index Cond", planstate, ancestors, es);
1967 "Order By", planstate, ancestors, es);
1973 case T_IndexOnlyScan:
1975 "Index Cond", planstate, ancestors, es);
1980 "Order By", planstate, ancestors, es);
1989 case T_BitmapIndexScan:
1991 "Index Cond", planstate, ancestors, es);
1993 case T_BitmapHeapScan:
1995 "Recheck Cond", planstate, ancestors, es);
2008 planstate, ancestors, es);
2014 case T_NamedTuplestoreScan:
2015 case T_WorkTableScan:
2016 case T_SubqueryScan:
2037 nworkers = ((
GatherState *) planstate)->nworkers_launched;
2067 case T_FunctionScan:
2081 "Function Call", planstate, ancestors,
2089 case T_TableFuncScan:
2095 "Table Function Call", planstate, ancestors,
2120 case T_TidRangeScan:
2158 "Join Filter", planstate, ancestors, es);
2169 "Merge Cond", planstate, ancestors, es);
2171 "Join Filter", planstate, ancestors, es);
2182 "Hash Cond", planstate, ancestors, es);
2184 "Join Filter", planstate, ancestors, es);
2207 "Run Condition", planstate, ancestors, es);
2220 case T_IncrementalSort:
2232 "One-Time Filter", planstate, ancestors, es);
2287 double nloops = instrument->
nloops;
2331 haschildren = planstate->
initPlan ||
2386 case T_SubqueryScan:
2388 "Subquery", NULL, es);
2411 es->
indent = save_indent;
2414 relationship ? NULL :
"Plan",
2463 foreach(lc,
plan->targetlist)
2531 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2545 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2557 plan->numCols, 0,
plan->sortColIdx,
2558 plan->sortOperators,
plan->collations,
2573 plan->sort.numCols,
plan->nPresortedCols,
2574 plan->sort.sortColIdx,
2575 plan->sort.sortOperators,
plan->sort.collations,
2576 plan->sort.nullsFirst,
2590 plan->numCols, 0,
plan->sortColIdx,
2591 plan->sortOperators,
plan->collations,
2610 if (
plan->groupingSets)
2639 context, useprefix, ancestors, es);
2641 foreach(lc, agg->
chain)
2647 context, useprefix, ancestors, es);
2664 const char *keyname;
2665 const char *keysetname;
2669 keyname =
"Hash Key";
2670 keysetname =
"Hash Keys";
2674 keyname =
"Group Key";
2675 keysetname =
"Group Keys";
2683 sortnode->
numCols, 0, sortnode->sortColIdx,
2684 sortnode->sortOperators, sortnode->collations,
2685 sortnode->nullsFirst,
2706 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2711 result =
lappend(result, exprstr);
2753 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
2754 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
2776 for (keyno = 0; keyno < nkeys; keyno++)
2785 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2792 if (sortOperators != NULL)
2795 sortOperators[keyno],
2800 if (keyno < nPresortedKeys)
2801 resultPresorted =
lappend(resultPresorted, exprstr);
2805 if (nPresortedKeys > 0)
2815 Oid sortOperator,
Oid collation,
bool nullsFirst)
2818 bool reverse =
false;
2835 if (collname == NULL)
2836 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2841 if (sortOperator == typentry->
gt_opr)
2846 else if (sortOperator != typentry->
lt_opr)
2851 elog(
ERROR,
"cache lookup failed for operator %u", sortOperator);
2858 if (nullsFirst && !reverse)
2862 else if (!nullsFirst && reverse)
2892 foreach(lc, tsc->
args)
2947 const char *sortMethod;
2948 const char *spaceType;
2954 spaceUsed = stats.spaceUsed;
2960 sortMethod, spaceType, spaceUsed);
2986 const char *sortMethod;
2987 const char *spaceType;
3005 sortMethod, spaceType, spaceUsed);
3059 foreach(methodCell, methodNames)
3069 const char *spaceTypeName;
3073 spaceTypeName, avgSpace,
3081 const char *spaceTypeName;
3085 spaceTypeName, avgSpace,
3103 const char *spaceTypeName;
3120 const char *spaceTypeName;
3180 bool indent_first_line;
3208 indent_first_line, es);
3276 if (hinstrument.
nbatch > 0)
3278 long spacePeakKb = (hinstrument.
space_peak + 1023) / 1024;
3298 "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: %ldkB\n",
3309 "Buckets: %d Batches: %d Memory Usage: %ldkB\n",
3381 memPeakKb = (mstate->
mem_used + 1023) / 1024;
3430 memPeakKb = (si->
mem_peak + 1023) / 1024;
3495 bool gotone =
false;
3539 uint64 hash_disk_used;
3540 int hash_batches_used;
3558 hash_batches_used, memPeakKb);
3561 if (hash_batches_used > 1)
3569 hash_batches_used, es);
3677 result = (*explain_get_index_name_hook) (indexId);
3685 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3701 bool has_shared_timing;
3702 bool has_local_timing;
3703 bool has_temp_timing;
3711 has_shared = (
usage->shared_blks_hit > 0 ||
3712 usage->shared_blks_read > 0 ||
3713 usage->shared_blks_dirtied > 0 ||
3714 usage->shared_blks_written > 0);
3715 has_local = (
usage->local_blks_hit > 0 ||
3716 usage->local_blks_read > 0 ||
3717 usage->local_blks_dirtied > 0 ||
3718 usage->local_blks_written > 0);
3719 has_temp = (
usage->temp_blks_read > 0 ||
3720 usage->temp_blks_written > 0);
3728 return has_shared || has_local || has_temp || has_shared_timing ||
3729 has_local_timing || has_temp_timing;
3740 bool has_shared = (
usage->shared_blks_hit > 0 ||
3741 usage->shared_blks_read > 0 ||
3742 usage->shared_blks_dirtied > 0 ||
3743 usage->shared_blks_written > 0);
3744 bool has_local = (
usage->local_blks_hit > 0 ||
3745 usage->local_blks_read > 0 ||
3746 usage->local_blks_dirtied > 0 ||
3747 usage->local_blks_written > 0);
3748 bool has_temp = (
usage->temp_blks_read > 0 ||
3749 usage->temp_blks_written > 0);
3758 if (has_shared || has_local || has_temp)
3766 if (
usage->shared_blks_hit > 0)
3768 (
long long)
usage->shared_blks_hit);
3769 if (
usage->shared_blks_read > 0)
3771 (
long long)
usage->shared_blks_read);
3772 if (
usage->shared_blks_dirtied > 0)
3774 (
long long)
usage->shared_blks_dirtied);
3775 if (
usage->shared_blks_written > 0)
3777 (
long long)
usage->shared_blks_written);
3778 if (has_local || has_temp)
3784 if (
usage->local_blks_hit > 0)
3786 (
long long)
usage->local_blks_hit);
3787 if (
usage->local_blks_read > 0)
3789 (
long long)
usage->local_blks_read);
3790 if (
usage->local_blks_dirtied > 0)
3792 (
long long)
usage->local_blks_dirtied);
3793 if (
usage->local_blks_written > 0)
3795 (
long long)
usage->local_blks_written);
3802 if (
usage->temp_blks_read > 0)
3804 (
long long)
usage->temp_blks_read);
3805 if (
usage->temp_blks_written > 0)
3807 (
long long)
usage->temp_blks_written);
3813 if (has_shared_timing || has_local_timing || has_temp_timing)
3818 if (has_shared_timing)
3827 if (has_local_timing || has_temp_timing)
3830 if (has_local_timing)
3839 if (has_temp_timing)
3842 if (has_temp_timing)
3858 usage->shared_blks_hit, es);
3860 usage->shared_blks_read, es);
3862 usage->shared_blks_dirtied, es);
3864 usage->shared_blks_written, es);
3866 usage->local_blks_hit, es);
3868 usage->local_blks_read, es);
3870 usage->local_blks_dirtied, es);
3872 usage->local_blks_written, es);
3874 usage->temp_blks_read, es);
3876 usage->temp_blks_written, es);
3910 if ((
usage->wal_records > 0) || (
usage->wal_fpi > 0) ||
3911 (
usage->wal_bytes > 0))
3916 if (
usage->wal_records > 0)
3918 (
long long)
usage->wal_records);
3919 if (
usage->wal_fpi > 0)
3921 (
long long)
usage->wal_fpi);
3922 if (
usage->wal_bytes > 0)
3931 usage->wal_records, es);
3933 usage->wal_fpi, es);
3935 usage->wal_bytes, es);
3949 "Memory: used=%lld bytes allocated=%lld bytes",
3982 const char *scandir;
3984 switch (indexorderdir)
3987 scandir =
"Backward";
3990 scandir =
"Forward";
4029 char *objectname = NULL;
4030 char *
namespace = NULL;
4031 const char *objecttag = NULL;
4037 if (refname == NULL)
4038 refname = rte->eref->aliasname;
4045 case T_IndexOnlyScan:
4046 case T_BitmapHeapScan:
4048 case T_TidRangeScan:
4057 objecttag =
"Relation Name";
4059 case T_FunctionScan:
4086 objecttag =
"Function Name";
4089 case T_TableFuncScan:
4097 objectname =
"xmltable";
4100 objectname =
"json_table";
4103 elog(
ERROR,
"invalid TableFunc type %d",
4106 objecttag =
"Table Function Name";
4115 Assert(!rte->self_reference);
4116 objectname = rte->ctename;
4117 objecttag =
"CTE Name";
4119 case T_NamedTuplestoreScan:
4121 objectname = rte->enrname;
4122 objecttag =
"Tuplestore Name";
4124 case T_WorkTableScan:
4127 Assert(rte->self_reference);
4128 objectname = rte->ctename;
4129 objecttag =
"CTE Name";
4138 if (
namespace != NULL)
4141 else if (objectname != NULL)
4143 if (objectname == NULL || strcmp(refname, objectname) != 0)
4148 if (objecttag != NULL && objectname != NULL)
4150 if (
namespace != NULL)
4169 const char *operation;
4170 const char *foperation;
4179 operation =
"Insert";
4180 foperation =
"Foreign Insert";
4183 operation =
"Update";
4184 foperation =
"Foreign Update";
4187 operation =
"Delete";
4188 foperation =
"Foreign Delete";
4191 operation =
"Merge";
4193 foperation =
"Foreign Merge";
4197 foperation =
"Foreign ???";
4202 labeltargets = (mtstate->
mt_nrels > 1 ||
4227 fdwroutine ? foperation : operation);
4244 fdwroutine != NULL &&
4272 idxNames =
lappend(idxNames, indexname);
4279 "NOTHING" :
"UPDATE",
4293 &mtstate->
ps, ancestors, es);
4309 insert_path = total - other_path;
4312 insert_path, 0, es);
4326 double skipped_path;
4335 skipped_path = total - insert_path - update_path - delete_path;
4336 Assert(skipped_path >= 0);
4344 if (insert_path > 0)
4346 if (update_path > 0)
4348 if (delete_path > 0)
4350 if (skipped_path > 0)
4382 for (
j = 0;
j < nplans;
j++)
4384 "Member", NULL, es);
4399 nchildren - nplans, es);
4439 ancestors =
lcons(sp, ancestors);
4496 Assert(n >= 0 && n < wstate->num_workers);
4558 Assert(n >= 0 && n < wstate->num_workers);
5126 "<explain xmlns=\"http://www.postgresql.org/2009/explain\">\n");
5208 const char *valid =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
5215 for (s = tagname; *s; s++)
5336 receiver->
nattrs = nattrs;
5342 for (
int i = 0;
i < nattrs;
i++)
5350 if (receiver->
format == 0)
5358 else if (receiver->
format == 1)
5368 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5369 errmsg(
"unsupported format code: %d", receiver->
format)));
5386 int natts = typeinfo->
natts;
5420 for (
int i = 0;
i < natts;
i++)
5431 if (myState->
format == 0)
5504 "SerializeTupleReceive",
void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
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 Assert(condition)
#define OidIsValid(objectId)
bool CreateTableAsRelExists(CreateTableAsStmt *ctas)
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
int GetIntoRelEFlags(IntoClause *intoClause)
bool defGetBoolean(DefElem *def)
char * defGetString(DefElem *def)
DestReceiver * None_Receiver
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecutorEnd(QueryDesc *queryDesc)
void ExecutorFinish(QueryDesc *queryDesc)
void ExecutorStart(QueryDesc *queryDesc, int eflags)
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
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)
static void serializeAnalyzeStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
static void ExplainDummyGroup(const char *objtype, const char *labelname, ExplainState *es)
static void show_plan_tlist(PlanState *planstate, List *ancestors, ExplainState *es)
static void show_memoize_info(MemoizeState *mstate, List *ancestors, ExplainState *es)
void ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
static void show_group_keys(GroupState *gstate, List *ancestors, ExplainState *es)
static void ExplainModifyTarget(ModifyTable *plan, ExplainState *es)
void ExplainOpenGroup(const char *objtype, const char *labelname, bool labeled, 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)
#define X_CLOSE_IMMEDIATE
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)
void ExplainPropertyUInteger(const char *qlabel, const char *unit, uint64 value, 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)
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)
void ExplainPropertyInteger(const char *qlabel, const char *unit, int64 value, ExplainState *es)
void ExplainPropertyListNested(const char *qlabel, List *data, ExplainState *es)
static void ExplainYAMLLineStarting(ExplainState *es)
DestReceiver * CreateExplainSerializeDestReceiver(ExplainState *es)
void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, ParamListInfo params, DestReceiver *dest)
static void show_incremental_sort_info(IncrementalSortState *incrsortstate, ExplainState *es)
static void serialize_prepare_info(SerializeDestReceiver *receiver, TupleDesc typeinfo, int nattrs)
struct SerializeMetrics SerializeMetrics
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)
void ExplainSeparatePlans(ExplainState *es)
static void ExplainMissingMembers(int nplans, int nchildren, ExplainState *es)
void ExplainEndOutput(ExplainState *es)
void ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
static void serializeAnalyzeDestroy(DestReceiver *self)
static void ExplainJSONLineEnding(ExplainState *es)
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 ExplainProperty(const char *qlabel, const char *unit, const char *value, bool numeric, ExplainState *es)
void ExplainPropertyFloat(const char *qlabel, const char *unit, double value, int ndigits, ExplainState *es)
void ExplainCloseGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es)
static void show_sortorder_options(StringInfo buf, Node *sortexpr, Oid sortOperator, Oid collation, bool nullsFirst)
static void show_expression(Node *node, const char *qlabel, PlanState *planstate, List *ancestors, bool useprefix, ExplainState *es)
static double elapsed_time(instr_time *starttime)
static void ExplainIndentText(ExplainState *es)
void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
static bool serializeAnalyzeReceive(TupleTableSlot *slot, DestReceiver *self)
static void ExplainRestoreGroup(ExplainState *es, int depth, int *state_save)
void ExplainBeginOutput(ExplainState *es)
ExplainState * NewExplainState(void)
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_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 escape_yaml(StringInfo buf, const char *str)
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 ExplainOneQuery(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
static void ExplainOpenWorker(int n, ExplainState *es)
struct SerializeDestReceiver SerializeDestReceiver
static void ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
static void ExplainSaveGroup(ExplainState *es, int depth, int *state_save)
static void ExplainXMLTag(const char *tagname, int flags, ExplainState *es)
static void show_wal_usage(ExplainState *es, const WalUsage *usage)
static void ExplainOpenSetAsideGroup(const char *objtype, const char *labelname, bool labeled, int depth, ExplainState *es)
void ExplainPropertyBool(const char *qlabel, bool value, 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_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 serializeAnalyzeShutdown(DestReceiver *self)
static void show_incremental_sort_keys(IncrementalSortState *incrsortstate, List *ancestors, ExplainState *es)
static void ExplainCustomChildren(CustomScanState *css, List *ancestors, ExplainState *es)
void ExplainPropertyList(const char *qlabel, List *data, ExplainState *es)
static SerializeMetrics GetSerializationMetrics(DestReceiver *dest)
@ EXPLAIN_SERIALIZE_BINARY
void(* ExplainOneQuery_hook_type)(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
const char *(* explain_get_index_name_hook_type)(Oid indexId)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
char * OutputFunctionCall(FmgrInfo *flinfo, Datum val)
struct config_generic ** get_explain_guc_options(int *num)
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
#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)
#define INSTR_TIME_ACCUM_DIFF(x, y, z)
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)
void escape_json(StringInfo buf, const char *str)
List * lcons_int(int datum, List *list)
List * lappend(List *list, void *datum)
List * list_delete_first(List *list)
List * lcons(void *datum, List *list)
char * get_opname(Oid opno)
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
char * get_namespace_name_or_temp(Oid nspid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
Oid get_rel_namespace(Oid relid)
Oid get_typcollation(Oid typid)
char * get_rel_name(Oid relid)
char * get_func_name(Oid funcid)
char * get_collation_name(Oid colloid)
char * get_constraint_name(Oid conoid)
Oid get_func_namespace(Oid funcid)
Expr * make_andclause(List *andclauses)
Expr * make_ands_explicit(List *andclauses)
Expr * make_orclause(List *orclauses)
void MemoryContextMemConsumed(MemoryContext context, MemoryContextCounters *consumed)
void MemoryContextReset(MemoryContext context)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#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)
char * BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen)
int parser_errposition(ParseState *pstate, int location)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
#define CURSOR_OPT_PARALLEL_OK
post_parse_analyze_hook_type post_parse_analyze_hook
#define rt_fetch(rangetable_index, rangetable)
FormData_pg_attribute * Form_pg_attribute
#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)
MemoryContextSwitchTo(old_ctx)
static const struct fns functions
#define RelationGetRelationName(relation)
List * QueryRewrite(Query *parsetree)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
const char * quote_identifier(const char *ident)
List * select_rtable_names_for_explain(List *rtable, Bitmapset *rels_used)
List * set_deparse_context_plan(List *dpcontext, Plan *plan, List *ancestors)
List * deparse_context_for_plan_tree(PlannedStmt *pstmt, List *rtable_names)
#define ScanDirectionIsBackward(direction)
@ NoMovementScanDirection
void UpdateActiveSnapshotCommandId(void)
void PopActiveSnapshot(void)
void PushCopiedSnapshot(Snapshot snapshot)
Snapshot GetActiveSnapshot(void)
StringInfo makeStringInfo(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)
#define appendStringInfoCharMacro(str, ch)
int hash_planned_partitions
SharedAggInfo * shared_info
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
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
ScanDirection indexorderdir
ScanDirection indexorderdir
instr_time generation_counter
instr_time optimization_counter
instr_time deform_counter
instr_time emission_counter
instr_time inlining_counter
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
Instrumentation * ri_TrigInstrument
TriggerDesc * ri_TrigDesc
struct FdwRoutine * ri_FdwRoutine
bool ri_usesFdwDirectModify
AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER]
IncrementalSortInfo sinfo[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
TupleDesc tts_tupleDescriptor
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)
#define TupleDescAttr(tupdesc, i)
const char * tuplesort_space_type_name(TuplesortSpaceType t)
void tuplesort_get_stats(Tuplesortstate *state, TuplesortInstrumentation *stats)
const char * tuplesort_method_name(TuplesortMethod m)
#define NUM_TUPLESORTMETHODS
@ SORT_TYPE_STILL_IN_PROGRESS
static void slot_getallattrs(TupleTableSlot *slot)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
static void usage(const char *progname)
Datum bit(PG_FUNCTION_ARGS)
void CommandCounterIncrement(void)
char * escape_xml(const char *str)