63 #define X_CLOSE_IMMEDIATE 2
64 #define X_NOWHITESPACE 4
70 #define BYTES_TO_KILOBYTES(b) (((b) + 1023) / 1024)
85 const char *relationship,
const char *plan_name,
118 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
119 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
122 Oid sortOperator,
Oid collation,
bool nullsFirst);
193 bool timing_set =
false;
194 bool summary_set =
false;
197 foreach(lc,
stmt->options)
201 if (strcmp(opt->
defname,
"analyze") == 0)
203 else if (strcmp(opt->
defname,
"verbose") == 0)
205 else if (strcmp(opt->
defname,
"costs") == 0)
207 else if (strcmp(opt->
defname,
"buffers") == 0)
209 else if (strcmp(opt->
defname,
"wal") == 0)
211 else if (strcmp(opt->
defname,
"settings") == 0)
213 else if (strcmp(opt->
defname,
"generic_plan") == 0)
215 else if (strcmp(opt->
defname,
"timing") == 0)
220 else if (strcmp(opt->
defname,
"summary") == 0)
225 else if (strcmp(opt->
defname,
"memory") == 0)
227 else if (strcmp(opt->
defname,
"serialize") == 0)
233 if (strcmp(p,
"off") == 0 || strcmp(p,
"none") == 0)
235 else if (strcmp(p,
"text") == 0)
237 else if (strcmp(p,
"binary") == 0)
241 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
242 errmsg(
"unrecognized value for EXPLAIN option \"%s\": \"%s\"",
252 else if (strcmp(opt->
defname,
"format") == 0)
256 if (strcmp(p,
"text") == 0)
258 else if (strcmp(p,
"xml") == 0)
260 else if (strcmp(p,
"json") == 0)
262 else if (strcmp(p,
"yaml") == 0)
266 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
267 errmsg(
"unrecognized value for EXPLAIN option \"%s\": \"%s\"",
273 (
errcode(ERRCODE_SYNTAX_ERROR),
274 errmsg(
"unrecognized EXPLAIN option \"%s\"",
282 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
283 errmsg(
"EXPLAIN option WAL requires ANALYZE")));
291 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
292 errmsg(
"EXPLAIN option TIMING requires ANALYZE")));
297 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
298 errmsg(
"EXPLAIN option SERIALIZE requires ANALYZE")));
303 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
304 errmsg(
"EXPLAIN options ANALYZE and GENERIC_PLAN cannot be used together")));
314 (*post_parse_analyze_hook) (pstate, query, jstate);
327 if (rewritten ==
NIL)
341 foreach(l, rewritten)
348 if (
lnext(rewritten, l) != NULL)
394 Oid result_type = TEXTOID;
397 foreach(lc,
stmt->options)
401 if (strcmp(opt->
defname,
"format") == 0)
405 if (strcmp(p,
"xml") == 0)
406 result_type = XMLOID;
407 else if (strcmp(p,
"json") == 0)
408 result_type = JSONOID;
410 result_type = TEXTOID;
444 (*ExplainOneQuery_hook) (query, cursorOptions, into, es,
445 queryString, params, queryEnv);
448 queryString, params, queryEnv);
481 "explain analyze planner context",
511 &planduration, (es->
buffers ? &bufusage : NULL),
512 es->
memory ? &mem_counters : NULL);
532 if (utilityStmt == NULL)
555 elog(
ERROR,
"unexpected object type: %d",
564 queryString, params, queryEnv);
583 queryString, params, queryEnv);
587 queryString, params, queryEnv);
599 "Utility statements have no plan structure\n");
627 double totaltime = 0;
629 int instrument_option = 0;
676 dest, params, queryEnv, instrument_option);
748 if (es->
summary && planduration)
824 for (
int i = 0;
i < num;
i++)
846 for (
int i = 0;
i < num;
i++)
959 routerels !=
NIL || targrels !=
NIL);
960 foreach(l, resultrels)
966 foreach(l, routerels)
1041 "Inlining", jit_flags &
PGJIT_INLINE ?
"true" :
"false",
1042 "Optimization", jit_flags &
PGJIT_OPT3 ?
"true" :
"false",
1043 "Expressions", jit_flags &
PGJIT_EXPR ?
"true" :
"false",
1044 "Deforming", jit_flags &
PGJIT_DEFORM ?
"true" :
"false");
1050 "Timing: %s %.3f ms (%s %.3f ms), %s %.3f ms, %s %.3f ms, %s %.3f ms, %s %.3f ms\n",
1190 if (params == NULL || params->
numParams <= 0 || maxlen == 0)
1194 if (
str &&
str[0] !=
'\0')
1214 char *conname = NULL;
1239 if (es->
verbose || conname == NULL)
1302 case T_IndexOnlyScan:
1303 case T_BitmapHeapScan:
1305 case T_TidRangeScan:
1306 case T_SubqueryScan:
1307 case T_FunctionScan:
1308 case T_TableFuncScan:
1311 case T_NamedTuplestoreScan:
1312 case T_WorkTableScan:
1369 const char *relationship,
const char *plan_name,
1375 const char *strategy = NULL;
1376 const char *partialmode = NULL;
1377 const char *operation = NULL;
1378 const char *custom_name = NULL;
1380 int save_indent = es->
indent;
1396 pname = sname =
"Result";
1399 pname = sname =
"ProjectSet";
1402 sname =
"ModifyTable";
1406 pname = operation =
"Insert";
1409 pname = operation =
"Update";
1412 pname = operation =
"Delete";
1415 pname = operation =
"Merge";
1423 pname = sname =
"Append";
1426 pname = sname =
"Merge Append";
1428 case T_RecursiveUnion:
1429 pname = sname =
"Recursive Union";
1432 pname = sname =
"BitmapAnd";
1435 pname = sname =
"BitmapOr";
1438 pname = sname =
"Nested Loop";
1442 sname =
"Merge Join";
1446 sname =
"Hash Join";
1449 pname = sname =
"Seq Scan";
1452 pname = sname =
"Sample Scan";
1455 pname = sname =
"Gather";
1458 pname = sname =
"Gather Merge";
1461 pname = sname =
"Index Scan";
1463 case T_IndexOnlyScan:
1464 pname = sname =
"Index Only Scan";
1466 case T_BitmapIndexScan:
1467 pname = sname =
"Bitmap Index Scan";
1469 case T_BitmapHeapScan:
1470 pname = sname =
"Bitmap Heap Scan";
1473 pname = sname =
"Tid Scan";
1475 case T_TidRangeScan:
1476 pname = sname =
"Tid Range Scan";
1478 case T_SubqueryScan:
1479 pname = sname =
"Subquery Scan";
1481 case T_FunctionScan:
1482 pname = sname =
"Function Scan";
1484 case T_TableFuncScan:
1485 pname = sname =
"Table Function Scan";
1488 pname = sname =
"Values Scan";
1491 pname = sname =
"CTE Scan";
1493 case T_NamedTuplestoreScan:
1494 pname = sname =
"Named Tuplestore Scan";
1496 case T_WorkTableScan:
1497 pname = sname =
"WorkTable Scan";
1500 sname =
"Foreign Scan";
1504 pname =
"Foreign Scan";
1505 operation =
"Select";
1508 pname =
"Foreign Insert";
1509 operation =
"Insert";
1512 pname =
"Foreign Update";
1513 operation =
"Update";
1516 pname =
"Foreign Delete";
1517 operation =
"Delete";
1525 sname =
"Custom Scan";
1528 pname =
psprintf(
"Custom Scan (%s)", custom_name);
1533 pname = sname =
"Materialize";
1536 pname = sname =
"Memoize";
1539 pname = sname =
"Sort";
1541 case T_IncrementalSort:
1542 pname = sname =
"Incremental Sort";
1545 pname = sname =
"Group";
1551 sname =
"Aggregate";
1555 pname =
"Aggregate";
1559 pname =
"GroupAggregate";
1560 strategy =
"Sorted";
1563 pname =
"HashAggregate";
1564 strategy =
"Hashed";
1567 pname =
"MixedAggregate";
1571 pname =
"Aggregate ???";
1578 partialmode =
"Partial";
1579 pname =
psprintf(
"%s %s", partialmode, pname);
1583 partialmode =
"Finalize";
1584 pname =
psprintf(
"%s %s", partialmode, pname);
1587 partialmode =
"Simple";
1591 pname = sname =
"WindowAgg";
1594 pname = sname =
"Unique";
1602 strategy =
"Sorted";
1605 pname =
"HashSetOp";
1606 strategy =
"Hashed";
1609 pname =
"SetOp ???";
1615 pname = sname =
"LockRows";
1618 pname = sname =
"Limit";
1621 pname = sname =
"Hash";
1624 pname = sname =
"???";
1629 relationship ? NULL :
"Plan",
1646 if (
plan->parallel_aware)
1648 if (
plan->async_capable)
1676 case T_BitmapHeapScan:
1678 case T_TidRangeScan:
1679 case T_SubqueryScan:
1680 case T_FunctionScan:
1681 case T_TableFuncScan:
1684 case T_WorkTableScan:
1689 if (((
Scan *)
plan)->scanrelid > 0)
1702 case T_IndexOnlyScan:
1712 case T_BitmapIndexScan:
1715 const char *indexname =
1732 const char *jointype;
1755 jointype =
"Right Semi";
1758 jointype =
"Right Anti";
1781 const char *setopcmd;
1786 setopcmd =
"Intersect";
1789 setopcmd =
"Intersect All";
1792 setopcmd =
"Except";
1795 setopcmd =
"Except All";
1816 plan->startup_cost,
plan->total_cost,
1817 plan->plan_rows,
plan->plan_width);
1857 " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)",
1858 startup_ms, total_ms, rows, nloops);
1861 " (actual rows=%.0f loops=%.0f)",
1905 double nloops = instrument->
nloops;
1912 startup_ms = 1000.0 * instrument->
startup / nloops;
1913 total_ms = 1000.0 * instrument->
total / nloops;
1914 rows = instrument->
ntuples / nloops;
1923 "actual time=%.3f..%.3f rows=%.0f loops=%.0f\n",
1924 startup_ms, total_ms, rows, nloops);
1927 "actual rows=%.0f loops=%.0f\n",
1973 "Index Cond", planstate, ancestors, es);
1978 "Order By", planstate, ancestors, es);
1984 case T_IndexOnlyScan:
1986 "Index Cond", planstate, ancestors, es);
1991 "Order By", planstate, ancestors, es);
2000 case T_BitmapIndexScan:
2002 "Index Cond", planstate, ancestors, es);
2004 case T_BitmapHeapScan:
2006 "Recheck Cond", planstate, ancestors, es);
2018 planstate, ancestors, es);
2024 case T_NamedTuplestoreScan:
2025 case T_WorkTableScan:
2026 case T_SubqueryScan:
2047 nworkers = ((
GatherState *) planstate)->nworkers_launched;
2077 case T_FunctionScan:
2091 "Function Call", planstate, ancestors,
2099 case T_TableFuncScan:
2105 "Table Function Call", planstate, ancestors,
2130 case T_TidRangeScan:
2168 "Join Filter", planstate, ancestors, es);
2179 "Merge Cond", planstate, ancestors, es);
2181 "Join Filter", planstate, ancestors, es);
2192 "Hash Cond", planstate, ancestors, es);
2194 "Join Filter", planstate, ancestors, es);
2217 "Run Condition", planstate, ancestors, es);
2230 case T_IncrementalSort:
2242 "One-Time Filter", planstate, ancestors, es);
2300 double nloops = instrument->
nloops;
2344 haschildren = planstate->
initPlan ||
2399 case T_SubqueryScan:
2401 "Subquery", NULL, es);
2424 es->
indent = save_indent;
2427 relationship ? NULL :
"Plan",
2476 foreach(lc,
plan->targetlist)
2544 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2558 show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
2570 plan->numCols, 0,
plan->sortColIdx,
2571 plan->sortOperators,
plan->collations,
2586 plan->sort.numCols,
plan->nPresortedCols,
2587 plan->sort.sortColIdx,
2588 plan->sort.sortOperators,
plan->sort.collations,
2589 plan->sort.nullsFirst,
2603 plan->numCols, 0,
plan->sortColIdx,
2604 plan->sortOperators,
plan->collations,
2623 if (
plan->groupingSets)
2652 context, useprefix, ancestors, es);
2654 foreach(lc, agg->
chain)
2660 context, useprefix, ancestors, es);
2677 const char *keyname;
2678 const char *keysetname;
2682 keyname =
"Hash Key";
2683 keysetname =
"Hash Keys";
2687 keyname =
"Group Key";
2688 keysetname =
"Group Keys";
2696 sortnode->
numCols, 0, sortnode->sortColIdx,
2697 sortnode->sortOperators, sortnode->collations,
2698 sortnode->nullsFirst,
2719 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2724 result =
lappend(result, exprstr);
2766 int nkeys,
int nPresortedKeys,
AttrNumber *keycols,
2767 Oid *sortOperators,
Oid *collations,
bool *nullsFirst,
2789 for (keyno = 0; keyno < nkeys; keyno++)
2798 elog(
ERROR,
"no tlist entry for key %d", keyresno);
2805 if (sortOperators != NULL)
2808 sortOperators[keyno],
2813 if (keyno < nPresortedKeys)
2814 resultPresorted =
lappend(resultPresorted, exprstr);
2818 if (nPresortedKeys > 0)
2828 Oid sortOperator,
Oid collation,
bool nullsFirst)
2831 bool reverse =
false;
2848 if (collname == NULL)
2849 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2854 if (sortOperator == typentry->
gt_opr)
2859 else if (sortOperator != typentry->
lt_opr)
2864 elog(
ERROR,
"cache lookup failed for operator %u", sortOperator);
2871 if (nullsFirst && !reverse)
2875 else if (!nullsFirst && reverse)
2905 foreach(lc, tsc->
args)
2960 const char *sortMethod;
2961 const char *spaceType;
2967 spaceUsed = stats.spaceUsed;
2973 sortMethod, spaceType, spaceUsed);
2999 const char *sortMethod;
3000 const char *spaceType;
3018 sortMethod, spaceType, spaceUsed);
3072 foreach(methodCell, methodNames)
3082 const char *spaceTypeName;
3086 spaceTypeName, avgSpace,
3094 const char *spaceTypeName;
3098 spaceTypeName, avgSpace,
3116 const char *spaceTypeName;
3133 const char *spaceTypeName;
3193 bool indent_first_line;
3221 indent_first_line, es);
3289 if (hinstrument.
nbatch > 0)
3311 "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: " UINT64_FORMAT "kB\n",
3322 "Buckets: %d Batches: %d Memory Usage: " UINT64_FORMAT "kB\n",
3337 const char *storageType;
3344 if (!es->
analyze || tupstore == NULL)
3544 bool gotone =
false;
3588 uint64 hash_disk_used;
3589 int hash_batches_used;
3607 hash_batches_used, memPeakKb);
3610 if (hash_batches_used > 1)
3618 hash_batches_used, es);
3661 if (planstate->
pstate != NULL)
3765 result = (*explain_get_index_name_hook) (indexId);
3773 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3789 bool has_shared_timing;
3790 bool has_local_timing;
3791 bool has_temp_timing;
3799 has_shared = (
usage->shared_blks_hit > 0 ||
3800 usage->shared_blks_read > 0 ||
3801 usage->shared_blks_dirtied > 0 ||
3802 usage->shared_blks_written > 0);
3803 has_local = (
usage->local_blks_hit > 0 ||
3804 usage->local_blks_read > 0 ||
3805 usage->local_blks_dirtied > 0 ||
3806 usage->local_blks_written > 0);
3807 has_temp = (
usage->temp_blks_read > 0 ||
3808 usage->temp_blks_written > 0);
3816 return has_shared || has_local || has_temp || has_shared_timing ||
3817 has_local_timing || has_temp_timing;
3828 bool has_shared = (
usage->shared_blks_hit > 0 ||
3829 usage->shared_blks_read > 0 ||
3830 usage->shared_blks_dirtied > 0 ||
3831 usage->shared_blks_written > 0);
3832 bool has_local = (
usage->local_blks_hit > 0 ||
3833 usage->local_blks_read > 0 ||
3834 usage->local_blks_dirtied > 0 ||
3835 usage->local_blks_written > 0);
3836 bool has_temp = (
usage->temp_blks_read > 0 ||
3837 usage->temp_blks_written > 0);
3846 if (has_shared || has_local || has_temp)
3854 if (
usage->shared_blks_hit > 0)
3856 (
long long)
usage->shared_blks_hit);
3857 if (
usage->shared_blks_read > 0)
3859 (
long long)
usage->shared_blks_read);
3860 if (
usage->shared_blks_dirtied > 0)
3862 (
long long)
usage->shared_blks_dirtied);
3863 if (
usage->shared_blks_written > 0)
3865 (
long long)
usage->shared_blks_written);
3866 if (has_local || has_temp)
3872 if (
usage->local_blks_hit > 0)
3874 (
long long)
usage->local_blks_hit);
3875 if (
usage->local_blks_read > 0)
3877 (
long long)
usage->local_blks_read);
3878 if (
usage->local_blks_dirtied > 0)
3880 (
long long)
usage->local_blks_dirtied);
3881 if (
usage->local_blks_written > 0)
3883 (
long long)
usage->local_blks_written);
3890 if (
usage->temp_blks_read > 0)
3892 (
long long)
usage->temp_blks_read);
3893 if (
usage->temp_blks_written > 0)
3895 (
long long)
usage->temp_blks_written);
3901 if (has_shared_timing || has_local_timing || has_temp_timing)
3906 if (has_shared_timing)
3915 if (has_local_timing || has_temp_timing)
3918 if (has_local_timing)
3927 if (has_temp_timing)
3930 if (has_temp_timing)
3946 usage->shared_blks_hit, es);
3948 usage->shared_blks_read, es);
3950 usage->shared_blks_dirtied, es);
3952 usage->shared_blks_written, es);
3954 usage->local_blks_hit, es);
3956 usage->local_blks_read, es);
3958 usage->local_blks_dirtied, es);
3960 usage->local_blks_written, es);
3962 usage->temp_blks_read, es);
3964 usage->temp_blks_written, es);
3998 if ((
usage->wal_records > 0) || (
usage->wal_fpi > 0) ||
3999 (
usage->wal_bytes > 0))
4004 if (
usage->wal_records > 0)
4006 (
long long)
usage->wal_records);
4007 if (
usage->wal_fpi > 0)
4009 (
long long)
usage->wal_fpi);
4010 if (
usage->wal_bytes > 0)
4019 usage->wal_records, es);
4021 usage->wal_fpi, es);
4023 usage->wal_bytes, es);
4042 memUsedkB, memAllocatedkB);
4070 const char *scandir;
4072 switch (indexorderdir)
4075 scandir =
"Backward";
4078 scandir =
"Forward";
4117 char *objectname = NULL;
4118 char *
namespace = NULL;
4119 const char *objecttag = NULL;
4125 if (refname == NULL)
4126 refname = rte->eref->aliasname;
4133 case T_IndexOnlyScan:
4134 case T_BitmapHeapScan:
4136 case T_TidRangeScan:
4145 objecttag =
"Relation Name";
4147 case T_FunctionScan:
4174 objecttag =
"Function Name";
4177 case T_TableFuncScan:
4185 objectname =
"xmltable";
4188 objectname =
"json_table";
4191 elog(
ERROR,
"invalid TableFunc type %d",
4194 objecttag =
"Table Function Name";
4203 Assert(!rte->self_reference);
4204 objectname = rte->ctename;
4205 objecttag =
"CTE Name";
4207 case T_NamedTuplestoreScan:
4209 objectname = rte->enrname;
4210 objecttag =
"Tuplestore Name";
4212 case T_WorkTableScan:
4215 Assert(rte->self_reference);
4216 objectname = rte->ctename;
4217 objecttag =
"CTE Name";
4226 if (
namespace != NULL)
4229 else if (objectname != NULL)
4231 if (objectname == NULL || strcmp(refname, objectname) != 0)
4236 if (objecttag != NULL && objectname != NULL)
4238 if (
namespace != NULL)
4257 const char *operation;
4258 const char *foperation;
4267 operation =
"Insert";
4268 foperation =
"Foreign Insert";
4271 operation =
"Update";
4272 foperation =
"Foreign Update";
4275 operation =
"Delete";
4276 foperation =
"Foreign Delete";
4279 operation =
"Merge";
4281 foperation =
"Foreign Merge";
4285 foperation =
"Foreign ???";
4290 labeltargets = (mtstate->
mt_nrels > 1 ||
4315 fdwroutine ? foperation : operation);
4332 fdwroutine != NULL &&
4360 idxNames =
lappend(idxNames, indexname);
4367 "NOTHING" :
"UPDATE",
4381 &mtstate->
ps, ancestors, es);
4397 insert_path = total - other_path;
4400 insert_path, 0, es);
4414 double skipped_path;
4423 skipped_path = total - insert_path - update_path - delete_path;
4424 Assert(skipped_path >= 0);
4432 if (insert_path > 0)
4434 if (update_path > 0)
4436 if (delete_path > 0)
4438 if (skipped_path > 0)
4470 for (
j = 0;
j < nplans;
j++)
4472 "Member", NULL, es);
4487 nchildren - nplans, es);
4527 ancestors =
lcons(sp, ancestors);
4584 Assert(n >= 0 && n < wstate->num_workers);
4646 Assert(n >= 0 && n < wstate->num_workers);
5214 "<explain xmlns=\"http://www.postgresql.org/2009/explain\">\n");
5296 const char *valid =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
5303 for (s = tagname; *s; s++)
5424 receiver->
nattrs = nattrs;
5430 for (
int i = 0;
i < nattrs;
i++)
5438 if (receiver->
format == 0)
5446 else if (receiver->
format == 1)
5456 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5457 errmsg(
"unsupported format code: %d", receiver->
format)));
5474 int natts = typeinfo->
natts;
5508 for (
int i = 0;
i < natts;
i++)
5519 if (myState->
format == 0)
5592 "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)
#define BYTES_TO_KILOBYTES(b)
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_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 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
ParallelBitmapHeapState * pstate
BitmapHeapScanInstrumentation stats
SharedBitmapHeapInstrumentation * sinstrument
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
Tuplestorestate * tuplestorestate
SharedMemoizeInfo * shared_info
MemoizeInstrumentation stats
ResultRelInfo * resultRelInfo
OnConflictAction onConflictAction
QueryEnvironment * p_queryEnv
const char * p_sourcetext
struct SharedJitInstrumentation * worker_jit_instrument
Instrumentation * instrument
WorkerInstrumentation * worker_instrument
PlannedStmt * plannedstmt
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]
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
int64 tuplestore_space_used(Tuplestorestate *state)
const char * tuplestore_storage_type_name(Tuplestorestate *state)
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)