MCPcopy Create free account
hub / github.com/apache/cloudberry / cdbexplain_showExecStatsEnd

Function cdbexplain_showExecStatsEnd

src/backend/commands/explain_gp.c:1898–1941  ·  view source on GitHub ↗

* cdbexplain_showExecStatsEnd * Called by qDisp process to format the overall statistics for a query * into the caller's buffer. * * 'ctx' is the CdbExplain_ShowStatCtx object which was created by a call to * cdbexplain_showExecStatsBegin() and contains statistics which have * been accumulated over a series of calls to cdbexplain_showExecStats(). * Invalid on return (it is freed). *

Source from the content-addressed store, hash-verified

1896 * they will be free'd shortly by the end of statement anyway.
1897 */
1898static void
1899cdbexplain_showExecStatsEnd(struct PlannedStmt *stmt,
1900 struct CdbExplain_ShowStatCtx *showstatctx,
1901 struct EState *estate,
1902 ExplainState *es)
1903{
1904 if (!es->summary)
1905 return;
1906
1907 gpexplain_formatSlicesOutput(showstatctx, estate, es);
1908
1909 if (!IsResManagerMemoryPolicyNone())
1910 {
1911 ExplainOpenGroup("Statement statistics", "Statement statistics", true, es);
1912 if (es->format == EXPLAIN_FORMAT_TEXT)
1913 appendStringInfo(es->str, "Memory used: %ldkB\n", (long) kb(stmt->query_mem));
1914 else
1915 ExplainPropertyInteger("Memory used", "kB", kb(stmt->query_mem), es);
1916
1917 if (showstatctx->workmemwanted_max > 0)
1918 {
1919 long mem_wanted;
1920
1921 mem_wanted = (long) PolicyAutoStatementMemForNoSpill(stmt,
1922 (uint64) showstatctx->workmemwanted_max);
1923
1924 /*
1925 * Round up to a kilobyte in case we end up requiring less than
1926 * that.
1927 */
1928 if (mem_wanted <= 1024L)
1929 mem_wanted = 1L;
1930 else
1931 mem_wanted = mem_wanted / 1024L;
1932
1933 if (es->format == EXPLAIN_FORMAT_TEXT)
1934 appendStringInfo(es->str, "Memory wanted: %ldkB\n", mem_wanted);
1935 else
1936 ExplainPropertyInteger("Memory wanted", "kB", mem_wanted, es);
1937 }
1938
1939 ExplainCloseGroup("Statement statistics", "Statement statistics", true, es);
1940 }
1941} /* cdbexplain_showExecStatsEnd */
1942
1943/*
1944 * Given a statistics context search for all the slice statistics

Callers 2

ExplainOnePlanFunction · 0.85
ExplainPrintExecStatsEndFunction · 0.85

Calls 6

ExplainOpenGroupFunction · 0.85
appendStringInfoFunction · 0.85
ExplainPropertyIntegerFunction · 0.85
ExplainCloseGroupFunction · 0.85

Tested by

no test coverage detected