diff options
author | David Rowley <drowley@postgresql.org> | 2021-07-14 12:43:58 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2021-07-14 12:43:58 +1200 |
commit | 83f4fcc65503c5d4e5d5eefc8e7a70d3c9a6496f (patch) | |
tree | 23c0962d1c255e8e6ca5cc29a0d1fe68e2d1223d /src/backend/commands/explain.c | |
parent | d68a00391214be2020e49be4b55f761d47a5c229 (diff) | |
download | postgresql-83f4fcc65503c5d4e5d5eefc8e7a70d3c9a6496f.tar.gz postgresql-83f4fcc65503c5d4e5d5eefc8e7a70d3c9a6496f.zip |
Change the name of the Result Cache node to Memoize
"Result Cache" was never a great name for this node, but nobody managed
to come up with another name that anyone liked enough. That was until
David Johnston mentioned "Node Memoization", which Tom Lane revised to
just "Memoize". People seem to like "Memoize", so let's do the rename.
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/20210708165145.GG1176@momjian.us
Backpatch-through: 14, where Result Cache was introduced
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index e81b9900925..340db2bac4d 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -109,8 +109,8 @@ static void show_sort_info(SortState *sortstate, ExplainState *es); static void show_incremental_sort_info(IncrementalSortState *incrsortstate, ExplainState *es); static void show_hash_info(HashState *hashstate, ExplainState *es); -static void show_resultcache_info(ResultCacheState *rcstate, List *ancestors, - ExplainState *es); +static void show_memoize_info(MemoizeState *mstate, List *ancestors, + ExplainState *es); static void show_hashagg_info(AggState *hashstate, ExplainState *es); static void show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es); @@ -1298,8 +1298,8 @@ ExplainNode(PlanState *planstate, List *ancestors, case T_Material: pname = sname = "Materialize"; break; - case T_ResultCache: - pname = sname = "Result Cache"; + case T_Memoize: + pname = sname = "Memoize"; break; case T_Sort: pname = sname = "Sort"; @@ -2013,9 +2013,9 @@ ExplainNode(PlanState *planstate, List *ancestors, case T_Hash: show_hash_info(castNode(HashState, planstate), es); break; - case T_ResultCache: - show_resultcache_info(castNode(ResultCacheState, planstate), - ancestors, es); + case T_Memoize: + show_memoize_info(castNode(MemoizeState, planstate), ancestors, + es); break; default: break; @@ -3085,13 +3085,12 @@ show_hash_info(HashState *hashstate, ExplainState *es) } /* - * Show information on result cache hits/misses/evictions and memory usage. + * Show information on memoize hits/misses/evictions and memory usage. */ static void -show_resultcache_info(ResultCacheState *rcstate, List *ancestors, - ExplainState *es) +show_memoize_info(MemoizeState *mstate, List *ancestors, ExplainState *es) { - Plan *plan = ((PlanState *) rcstate)->plan; + Plan *plan = ((PlanState *) mstate)->plan; ListCell *lc; List *context; StringInfoData keystr; @@ -3102,7 +3101,7 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors, initStringInfo(&keystr); /* - * It's hard to imagine having a result cache with fewer than 2 RTEs, but + * It's hard to imagine having a memoize node with fewer than 2 RTEs, but * let's just keep the same useprefix logic as elsewhere in this file. */ useprefix = list_length(es->rtable) > 1 || es->verbose; @@ -3112,7 +3111,7 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors, plan, ancestors); - foreach(lc, ((ResultCache *) plan)->param_exprs) + foreach(lc, ((Memoize *) plan)->param_exprs) { Node *expr = (Node *) lfirst(lc); @@ -3138,23 +3137,23 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors, if (!es->analyze) return; - if (rcstate->stats.cache_misses > 0) + if (mstate->stats.cache_misses > 0) { /* * mem_peak is only set when we freed memory, so we must use mem_used * when mem_peak is 0. */ - if (rcstate->stats.mem_peak > 0) - memPeakKb = (rcstate->stats.mem_peak + 1023) / 1024; + if (mstate->stats.mem_peak > 0) + memPeakKb = (mstate->stats.mem_peak + 1023) / 1024; else - memPeakKb = (rcstate->mem_used + 1023) / 1024; + memPeakKb = (mstate->mem_used + 1023) / 1024; if (es->format != EXPLAIN_FORMAT_TEXT) { - ExplainPropertyInteger("Cache Hits", NULL, rcstate->stats.cache_hits, es); - ExplainPropertyInteger("Cache Misses", NULL, rcstate->stats.cache_misses, es); - ExplainPropertyInteger("Cache Evictions", NULL, rcstate->stats.cache_evictions, es); - ExplainPropertyInteger("Cache Overflows", NULL, rcstate->stats.cache_overflows, es); + ExplainPropertyInteger("Cache Hits", NULL, mstate->stats.cache_hits, es); + ExplainPropertyInteger("Cache Misses", NULL, mstate->stats.cache_misses, es); + ExplainPropertyInteger("Cache Evictions", NULL, mstate->stats.cache_evictions, es); + ExplainPropertyInteger("Cache Overflows", NULL, mstate->stats.cache_overflows, es); ExplainPropertyInteger("Peak Memory Usage", "kB", memPeakKb, es); } else @@ -3162,23 +3161,23 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors, ExplainIndentText(es); appendStringInfo(es->str, "Hits: " UINT64_FORMAT " Misses: " UINT64_FORMAT " Evictions: " UINT64_FORMAT " Overflows: " UINT64_FORMAT " Memory Usage: " INT64_FORMAT "kB\n", - rcstate->stats.cache_hits, - rcstate->stats.cache_misses, - rcstate->stats.cache_evictions, - rcstate->stats.cache_overflows, + mstate->stats.cache_hits, + mstate->stats.cache_misses, + mstate->stats.cache_evictions, + mstate->stats.cache_overflows, memPeakKb); } } - if (rcstate->shared_info == NULL) + if (mstate->shared_info == NULL) return; /* Show details from parallel workers */ - for (int n = 0; n < rcstate->shared_info->num_workers; n++) + for (int n = 0; n < mstate->shared_info->num_workers; n++) { - ResultCacheInstrumentation *si; + MemoizeInstrumentation *si; - si = &rcstate->shared_info->sinstrument[n]; + si = &mstate->shared_info->sinstrument[n]; /* * Skip workers that didn't do any work. We needn't bother checking @@ -3191,10 +3190,10 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors, ExplainOpenWorker(n, es); /* - * Since the worker's ResultCacheState.mem_used field is unavailable - * to us, ExecEndResultCache will have set the - * ResultCacheInstrumentation.mem_peak field for us. No need to do - * the zero checks like we did for the serial case above. + * Since the worker's MemoizeState.mem_used field is unavailable to + * us, ExecEndMemoize will have set the + * MemoizeInstrumentation.mem_peak field for us. No need to do the + * zero checks like we did for the serial case above. */ memPeakKb = (si->mem_peak + 1023) / 1024; |