53 #define X_CLOSE_IMMEDIATE 2
54 #define X_NOWHITESPACE 4
67 const char *relationship,
const char *plan_name,
95 List *context,
bool useprefix,
100 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
101 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
104 Oid sortOperator,
Oid collation,
bool nullsFirst);
174 bool timing_set =
false;
175 bool summary_set =
false;
178 foreach(lc,
stmt->options)
182 if (strcmp(opt->
defname,
"analyze") == 0)
184 else if (strcmp(opt->
defname,
"verbose") == 0)
186 else if (strcmp(opt->
defname,
"costs") == 0)
188 else if (strcmp(opt->
defname,
"buffers") == 0)
190 else if (strcmp(opt->
defname,
"wal") == 0)
192 else if (strcmp(opt->
defname,
"settings") == 0)
194 else if (strcmp(opt->
defname,
"generic_plan") == 0)
196 else if (strcmp(opt->
defname,
"timing") == 0)
201 else if (strcmp(opt->
defname,
"summary") == 0)
206 else if (strcmp(opt->
defname,
"memory") == 0)
208 else if (strcmp(opt->
defname,
"format") == 0)
212 if (strcmp(p,
"text") == 0)
214 else if (strcmp(p,
"xml") == 0)
216 else if (strcmp(p,
"json") == 0)
218 else if (strcmp(p,
"yaml") == 0)
222 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
223 errmsg(
"unrecognized value for EXPLAIN option \"%s\": \"%s\"",
229 (
errcode(ERRCODE_SYNTAX_ERROR),
230 errmsg(
"unrecognized EXPLAIN option \"%s\"",
238 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
239 errmsg(
"EXPLAIN option WAL requires ANALYZE")));
247 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
248 errmsg(
"EXPLAIN option TIMING requires ANALYZE")));
253 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
254 errmsg(
"EXPLAIN options ANALYZE and GENERIC_PLAN cannot be used together")));
264 (*post_parse_analyze_hook) (pstate, query, jstate);
277 if (rewritten ==
NIL)
291 foreach(l, rewritten)
298 if (
lnext(rewritten, l) != NULL)
344 Oid result_type = TEXTOID;
347 foreach(lc,
stmt->options)
351 if (strcmp(opt->
defname,
"format") == 0)
355 if (strcmp(p,
"xml") == 0)
356 result_type = XMLOID;
357 else if (strcmp(p,
"json") == 0)
358 result_type = JSONOID;
360 result_type = TEXTOID;
394 (*ExplainOneQuery_hook) (query, cursorOptions, into, es,
395 queryString, params, queryEnv);
398 queryString, params, queryEnv);
431 "explain analyze planner context",
461 &planduration, (es->
buffers ? &bufusage : NULL),
462 es->
memory ? &mem_counters : NULL);
482 if (utilityStmt == NULL)
505 elog(
ERROR,
"unexpected object type: %d",
514 queryString, params, queryEnv);
533 queryString, params, queryEnv);
537 queryString, params, queryEnv);
549 "Utility statements have no plan structure\n");
577 double totaltime = 0;
579 int instrument_option = 0;
619 dest, params, queryEnv, instrument_option);
684 if (es->
summary && planduration)
756 for (
int i = 0;
i < num;
i++)
778 for (
int i = 0;
i < num;
i++)
891 routerels !=
NIL || targrels !=
NIL);
892 foreach(l, resultrels)
898 foreach(l, routerels)
973 "Inlining", jit_flags &
PGJIT_INLINE ?
"true" :
"false",
974 "Optimization", jit_flags &
PGJIT_OPT3 ?
"true" :
"false",
975 "Expressions", jit_flags &
PGJIT_EXPR ?
"true" :
"false",
976 "Deforming", jit_flags &
PGJIT_DEFORM ?
"true" :
"false");
982 "Timing: %s %.3f ms (%s %.3f ms), %s %.3f ms, %s %.3f ms, %s %.3f ms, %s %.3f ms\n",
1066 if (params == NULL || params->
numParams <= 0 || maxlen == 0)
1070 if (
str &&
str[0] !=
'\0')
1090 char *conname = NULL;
1115 if (es->
verbose || conname == NULL)
1178 case T_IndexOnlyScan:
1179 case T_BitmapHeapScan:
1181 case T_TidRangeScan:
1182 case T_SubqueryScan:
1183 case T_FunctionScan:
1184 case T_TableFuncScan:
1187 case T_NamedTuplestoreScan:
1188 case T_WorkTableScan:
1245 const char *relationship,
const char *plan_name,
1251 const char *strategy = NULL;
1252 const char *partialmode = NULL;
1253 const char *operation = NULL;
1254 const char *custom_name = NULL;
1256 int save_indent = es->
indent;
1272 pname = sname =
"Result";
1275 pname = sname =
"ProjectSet";
1278 sname =
"ModifyTable";
1282 pname = operation =
"Insert";
1285 pname = operation =
"Update";
1288 pname = operation =
"Delete";
1291 pname = operation =
"Merge";
1299 pname = sname =
"Append";
1302 pname = sname =
"Merge Append";
1304 case T_RecursiveUnion:
1305 pname = sname =
"Recursive Union";
1308 pname = sname =
"BitmapAnd";
1311 pname = sname =
"BitmapOr";
1314 pname = sname =
"Nested Loop";
1318 sname =
"Merge Join";
1322 sname =
"Hash Join";
1325 pname = sname =
"Seq Scan";
1328 pname = sname =
"Sample Scan";
1331 pname = sname =
"Gather";
1334 pname = sname =
"Gather Merge";
1337 pname = sname =
"Index Scan";
1339 case T_IndexOnlyScan:
1340 pname = sname =
"Index Only Scan";
1342 case T_BitmapIndexScan:
1343 pname = sname =
"Bitmap Index Scan";
1345 case T_BitmapHeapScan:
1346 pname = sname =
"Bitmap Heap Scan";
1349 pname = sname =
"Tid Scan";
1351 case T_TidRangeScan:
1352 pname = sname =
"Tid Range Scan";
1354 case T_SubqueryScan:
1355 pname = sname =
"Subquery Scan";
1357 case T_FunctionScan:
1358 pname = sname =
"Function Scan";
1360 case T_TableFuncScan:
1361 pname = sname =
"Table Function Scan";
1364 pname = sname =
"Values Scan";
1367 pname = sname =
"CTE Scan";
1369 case T_NamedTuplestoreScan:
1370 pname = sname =
"Named Tuplestore Scan";
1372 case T_WorkTableScan:
1373 pname = sname =
"WorkTable Scan";
1376 sname =
"Foreign Scan";
1380 pname =
"Foreign Scan";
1381 operation =
"Select";
1384 pname =
"Foreign Insert";
1385 operation =
"Insert";
1388 pname =
"Foreign Update";
1389 operation =
"Update";
1392 pname =
"Foreign Delete";
1393 operation =
"Delete";
1401 sname =
"Custom Scan";
1404 pname =
psprintf(
"Custom Scan (%s)", custom_name);
1409 pname = sname =
"Materialize";
1412 pname = sname =
"Memoize";
1415 pname = sname =
"Sort";
1417 case T_IncrementalSort:
1418 pname = sname =
"Incremental Sort";
1421 pname = sname =
"Group";
1427 sname =
"Aggregate";
1431 pname =
"Aggregate";
1435 pname =
"GroupAggregate";
1436 strategy =
"Sorted";
1439 pname =
"HashAggregate";
1440 strategy =
"Hashed";
1443 pname =
"MixedAggregate";
1447 pname =
"Aggregate ???";
1454 partialmode =
"Partial";
1455 pname =
psprintf(
"%s %s", partialmode, pname);
1459 partialmode =
"Finalize";
1460 pname =
psprintf(
"%s %s", partialmode, pname);
1463 partialmode =
"Simple";
1467 pname = sname =
"WindowAgg";
1470 pname = sname =
"Unique";
1478 strategy =
"Sorted";
1481 pname =
"HashSetOp";
1482 strategy =
"Hashed";
1485 pname =
"SetOp ???";
1491 pname = sname =
"LockRows";
1494 pname = sname =
"Limit";
1497 pname = sname =
"Hash";
1500 pname = sname =
"???";
1505 relationship ? NULL :
"Plan",
1522 if (
plan->parallel_aware)
1524 if (
plan->async_capable)
1552 case T_BitmapHeapScan:
1554 case T_TidRangeScan:
1555 case T_SubqueryScan:
1556 case T_FunctionScan:
1557 case T_TableFuncScan:
1560 case T_WorkTableScan:
1565 if (((
Scan *)
plan)->scanrelid > 0)
1578 case T_IndexOnlyScan:
1588 case T_BitmapIndexScan:
1591 const char *indexname =
1608 const char *jointype;
1631 jointype =
"Right Anti";
1654 const char *setopcmd;
1659 setopcmd =
"Intersect";
1662 setopcmd =
"Intersect All";
1665 setopcmd =
"Except";
1668 setopcmd =
"Except All";
1689 plan->startup_cost,
plan->total_cost,
1690 plan->plan_rows,
plan->plan_width);
1730 " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)",
1731 startup_ms, total_ms, rows, nloops);
1734 " (actual rows=%.0f loops=%.0f)",
1778 double nloops = instrument->
nloops;
1785 startup_ms = 1000.0 * instrument->
startup / nloops;
1786 total_ms = 1000.0 * instrument->
total / nloops;
1787 rows = instrument->
ntuples / nloops;
1796 "actual time=%.3f..%.3f rows=%.0f loops=%.0f\n",
1797 startup_ms, total_ms, rows, nloops);
1800 "actual rows=%.0f loops=%.0f\n",
1846 "Index Cond", planstate, ancestors, es);
1851 "Order By", planstate, ancestors, es);
1857 case T_IndexOnlyScan:
1859 "Index Cond", planstate, ancestors, es);
1864 "Order By", planstate, ancestors, es);
1873 case T_BitmapIndexScan:
1875 "Index Cond", planstate, ancestors, es);
1877 case T_BitmapHeapScan:
1879 "Recheck Cond", planstate, ancestors, es);
1892 planstate, ancestors, es);
1898 case T_NamedTuplestoreScan:
1899 case T_WorkTableScan:
1900 case T_SubqueryScan:
1925 nworkers = ((
GatherState *) planstate)->nworkers_launched;
1959 case T_FunctionScan:
1973 "Function Call", planstate, ancestors,
1981 case T_TableFuncScan:
1987 "Table Function Call", planstate, ancestors,
2012 case T_TidRangeScan:
2050 "Join Filter", planstate, ancestors, es);
2061 "Merge Cond", planstate, ancestors, es);
2063 "Join Filter", planstate, ancestors, es);
2074 "Hash Cond", planstate, ancestors, es);
2076 "Join Filter", planstate, ancestors, es);
2099 "Run Condition", planstate, ancestors, es);
2112 case T_IncrementalSort:
2124 "One-Time Filter", planstate, ancestors, es);
2179 double nloops = instrument->
nloops;
2223 haschildren = planstate->
initPlan ||
2278 case T_SubqueryScan:
2280 "Subquery", NULL, es);
2303 es->
indent = save_indent;
2306 relationship ? NULL :
"Plan",
2355 foreach(lc,
plan->targetlist)
2423 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2437 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2449 plan->numCols, 0,
plan->sortColIdx,
2450 plan->sortOperators,
plan->collations,
2465 plan->sort.numCols,
plan->nPresortedCols,
2466 plan->sort.sortColIdx,
2467 plan->sort.sortOperators,
plan->sort.collations,
2468 plan->sort.nullsFirst,
2482 plan->numCols, 0,
plan->sortColIdx,
2483 plan->sortOperators,
plan->collations,
2502 if (
plan->groupingSets)
2531 context, useprefix, ancestors, es);
2533 foreach(lc, agg->
chain)
2539 context, useprefix, ancestors, es);
2556 const char *keyname;
2557 const char *keysetname;
2561 keyname =
"Hash Key";
2562 keysetname =
"Hash Keys";
2566 keyname =
"Group Key";
2567 keysetname =
"Group Keys";
2575 sortnode->
numCols, 0, sortnode->sortColIdx,
2576 sortnode->sortOperators, sortnode->collations,
2577 sortnode->nullsFirst,
2598 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2603 result =
lappend(result, exprstr);
2645 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
2646 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
2668 for (keyno = 0; keyno < nkeys; keyno++)
2677 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2684 if (sortOperators != NULL)
2687 sortOperators[keyno],
2692 if (keyno < nPresortedKeys)
2693 resultPresorted =
lappend(resultPresorted, exprstr);
2697 if (nPresortedKeys > 0)
2707 Oid sortOperator,
Oid collation,
bool nullsFirst)
2710 bool reverse =
false;
2727 if (collname == NULL)
2728 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2733 if (sortOperator == typentry->
gt_opr)
2738 else if (sortOperator != typentry->
lt_opr)
2743 elog(
ERROR,
"cache lookup failed for operator %u", sortOperator);
2750 if (nullsFirst && !reverse)
2754 else if (!nullsFirst && reverse)
2784 foreach(lc, tsc->
args)
2839 const char *sortMethod;
2840 const char *spaceType;
2846 spaceUsed = stats.spaceUsed;
2852 sortMethod, spaceType, spaceUsed);
2878 const char *sortMethod;
2879 const char *spaceType;
2897 sortMethod, spaceType, spaceUsed);
2951 foreach(methodCell, methodNames)
2961 const char *spaceTypeName;
2965 spaceTypeName, avgSpace,
2973 const char *spaceTypeName;
2977 spaceTypeName, avgSpace,
2995 const char *spaceTypeName;
3012 const char *spaceTypeName;
3072 bool indent_first_line;
3100 indent_first_line, es);
3168 if (hinstrument.
nbatch > 0)
3170 long spacePeakKb = (hinstrument.
space_peak + 1023) / 1024;
3190 "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: %ldkB\n",
3201 "Buckets: %d Batches: %d Memory Usage: %ldkB\n",
3273 memPeakKb = (mstate->
mem_used + 1023) / 1024;
3322 memPeakKb = (si->
mem_peak + 1023) / 1024;
3387 bool gotone =
false;
3431 uint64 hash_disk_used;
3432 int hash_batches_used;
3450 hash_batches_used, memPeakKb);
3453 if (hash_batches_used > 1)
3461 hash_batches_used, es);
3568 snprintf(param,
sizeof(param),
"$%d", paramid);
3592 result = (*explain_get_index_name_hook) (indexId);
3600 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3616 bool has_shared_timing;
3617 bool has_local_timing;
3618 bool has_temp_timing;
3626 has_shared = (
usage->shared_blks_hit > 0 ||
3627 usage->shared_blks_read > 0 ||
3628 usage->shared_blks_dirtied > 0 ||
3629 usage->shared_blks_written > 0);
3630 has_local = (
usage->local_blks_hit > 0 ||
3631 usage->local_blks_read > 0 ||
3632 usage->local_blks_dirtied > 0 ||
3633 usage->local_blks_written > 0);
3634 has_temp = (
usage->temp_blks_read > 0 ||
3635 usage->temp_blks_written > 0);
3643 return has_shared || has_local || has_temp || has_shared_timing ||
3644 has_local_timing || has_temp_timing;
3655 bool has_shared = (
usage->shared_blks_hit > 0 ||
3656 usage->shared_blks_read > 0 ||
3657 usage->shared_blks_dirtied > 0 ||
3658 usage->shared_blks_written > 0);
3659 bool has_local = (
usage->local_blks_hit > 0 ||
3660 usage->local_blks_read > 0 ||
3661 usage->local_blks_dirtied > 0 ||
3662 usage->local_blks_written > 0);
3663 bool has_temp = (
usage->temp_blks_read > 0 ||
3664 usage->temp_blks_written > 0);
3673 if (has_shared || has_local || has_temp)
3681 if (
usage->shared_blks_hit > 0)
3683 (
long long)
usage->shared_blks_hit);
3684 if (
usage->shared_blks_read > 0)
3686 (
long long)
usage->shared_blks_read);
3687 if (
usage->shared_blks_dirtied > 0)
3689 (
long long)
usage->shared_blks_dirtied);
3690 if (
usage->shared_blks_written > 0)
3692 (
long long)
usage->shared_blks_written);
3693 if (has_local || has_temp)
3699 if (
usage->local_blks_hit > 0)
3701 (
long long)
usage->local_blks_hit);
3702 if (
usage->local_blks_read > 0)
3704 (
long long)
usage->local_blks_read);
3705 if (
usage->local_blks_dirtied > 0)
3707 (
long long)
usage->local_blks_dirtied);
3708 if (
usage->local_blks_written > 0)
3710 (
long long)
usage->local_blks_written);
3717 if (
usage->temp_blks_read > 0)
3719 (
long long)
usage->temp_blks_read);
3720 if (
usage->temp_blks_written > 0)
3722 (
long long)
usage->temp_blks_written);
3728 if (has_shared_timing || has_local_timing || has_temp_timing)
3733 if (has_shared_timing)
3742 if (has_local_timing || has_temp_timing)
3745 if (has_local_timing)
3754 if (has_temp_timing)
3757 if (has_temp_timing)
3773 usage->shared_blks_hit, es);
3775 usage->shared_blks_read, es);
3777 usage->shared_blks_dirtied, es);
3779 usage->shared_blks_written, es);
3781 usage->local_blks_hit, es);
3783 usage->local_blks_read, es);
3785 usage->local_blks_dirtied, es);
3787 usage->local_blks_written, es);
3789 usage->temp_blks_read, es);
3791 usage->temp_blks_written, es);
3825 if ((
usage->wal_records > 0) || (
usage->wal_fpi > 0) ||
3826 (
usage->wal_bytes > 0))
3831 if (
usage->wal_records > 0)
3833 (
long long)
usage->wal_records);
3834 if (
usage->wal_fpi > 0)
3836 (
long long)
usage->wal_fpi);
3837 if (
usage->wal_bytes > 0)
3846 usage->wal_records, es);
3848 usage->wal_fpi, es);
3850 usage->wal_bytes, es);
3864 "Memory: used=%lld bytes allocated=%lld bytes",
3897 const char *scandir;
3899 switch (indexorderdir)
3902 scandir =
"Backward";
3905 scandir =
"Forward";
3944 char *objectname = NULL;
3945 char *
namespace = NULL;
3946 const char *objecttag = NULL;
3952 if (refname == NULL)
3960 case T_IndexOnlyScan:
3961 case T_BitmapHeapScan:
3963 case T_TidRangeScan:
3972 objecttag =
"Relation Name";
3974 case T_FunctionScan:
4001 objecttag =
"Function Name";
4004 case T_TableFuncScan:
4006 objectname =
"xmltable";
4007 objecttag =
"Table Function Name";
4015 Assert(!rte->self_reference);
4016 objectname = rte->ctename;
4017 objecttag =
"CTE Name";
4019 case T_NamedTuplestoreScan:
4021 objectname = rte->enrname;
4022 objecttag =
"Tuplestore Name";
4024 case T_WorkTableScan:
4027 Assert(rte->self_reference);
4028 objectname = rte->ctename;
4029 objecttag =
"CTE Name";
4038 if (
namespace != NULL)
4041 else if (objectname != NULL)
4043 if (objectname == NULL || strcmp(refname, objectname) != 0)
4048 if (objecttag != NULL && objectname != NULL)
4050 if (
namespace != NULL)
4069 const char *operation;
4070 const char *foperation;
4079 operation =
"Insert";
4080 foperation =
"Foreign Insert";
4083 operation =
"Update";
4084 foperation =
"Foreign Update";
4087 operation =
"Delete";
4088 foperation =
"Foreign Delete";
4091 operation =
"Merge";
4093 foperation =
"Foreign Merge";
4097 foperation =
"Foreign ???";
4102 labeltargets = (mtstate->
mt_nrels > 1 ||
4127 fdwroutine ? foperation : operation);
4144 fdwroutine != NULL &&
4172 idxNames =
lappend(idxNames, indexname);
4179 "NOTHING" :
"UPDATE",
4193 &mtstate->
ps, ancestors, es);
4209 insert_path = total - other_path;
4212 insert_path, 0, es);
4226 double skipped_path;
4235 skipped_path = total - insert_path - update_path - delete_path;
4236 Assert(skipped_path >= 0);
4244 if (insert_path > 0)
4246 if (update_path > 0)
4248 if (delete_path > 0)
4250 if (skipped_path > 0)
4282 for (
j = 0;
j < nplans;
j++)
4284 "Member", NULL, es);
4299 nchildren - nplans, es);
4339 ancestors =
lcons(sp, ancestors);
4396 Assert(n >= 0 && n < wstate->num_workers);
4458 Assert(n >= 0 && n < wstate->num_workers);
5026 "<explain xmlns=\"http://www.postgresql.org/2009/explain\">\n");
5108 const char *valid =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
5115 for (s = tagname; *s; s++)
void ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
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)
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 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_eval_params(Bitmapset *bms_params, ExplainState *es)
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)
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)
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 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 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 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)
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 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)
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)
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)
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)
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
char * get_namespace_name_or_temp(Oid nspid)
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)
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)
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)
#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)
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
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
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)
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
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)