Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c80e96

Browse files
committed
Adjust EXPLAIN output for parallel Result Cache plans
Here we adjust the EXPLAIN ANALYZE output for Result Cache so that wedon't show any Result Cache stats for parallel workers who don'tcontribute anything to Result Cache plan nodes.I originally had ideas that workers who don't help could still have theirResult Cache stats displayed. The idea with that was so that I couldwrite some parallel Result Cache regression tests that show the EXPLAINANALYZE output. However, I realized a little too late that such testswould just not be possible to have run in a stable way on the buildfarm.With that knowledge, before9eacee2 went in, I had removed all of thetests that were showing the EXPLAIN ANALYZE output of a parallel ResultCache plan, however, I forgot to put back the code that adjusts theEXPLAIN output to hide the Result Cache stats for parallel workers whowere not fast enough to help out before query execution was over. Allother nodes behave this way and so should Result Cache.Additionally, with this change, it now seems safe enough to remove the SETforce_parallel_mode = off that I had added to the regression tests.Also, perform some cleanup in the partition_prune tests. I had adjustedthe explain_parallel_append() function to sanitize the Result CacheEXPLAIN ANALYZE output. However, since I didn't actually include anyparallel Result Cache tests that show their EXPLAIN ANALYZE output, thatcode does nothing and can be removed.In passing, move the setting of memPeakKb into the scope where it's used.Reported-by: Amit KhandekarAuthor: David Rowley, Amit KhandekarDiscussion:https://postgr.es/m/CAJ3gD9d8SkfY95GpM1zmsOtX2-Ogx5q-WLsf8f0ykEb0hCRK3w@mail.gmail.com
1 parent51ef917 commit3c80e96

File tree

5 files changed

+17
-23
lines changed

5 files changed

+17
-23
lines changed

‎src/backend/commands/explain.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,17 +3144,17 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors,
31443144
if (!es->analyze)
31453145
return;
31463146

3147-
/*
3148-
* mem_peak is only set when we freed memory, so we must use mem_used when
3149-
* mem_peak is 0.
3150-
*/
3151-
if (rcstate->stats.mem_peak>0)
3152-
memPeakKb= (rcstate->stats.mem_peak+1023) /1024;
3153-
else
3154-
memPeakKb= (rcstate->mem_used+1023) /1024;
3155-
31563147
if (rcstate->stats.cache_misses>0)
31573148
{
3149+
/*
3150+
* mem_peak is only set when we freed memory, so we must use mem_used
3151+
* when mem_peak is 0.
3152+
*/
3153+
if (rcstate->stats.mem_peak>0)
3154+
memPeakKb= (rcstate->stats.mem_peak+1023) /1024;
3155+
else
3156+
memPeakKb= (rcstate->mem_used+1023) /1024;
3157+
31583158
if (es->format!=EXPLAIN_FORMAT_TEXT)
31593159
{
31603160
ExplainPropertyInteger("Cache Hits",NULL,rcstate->stats.cache_hits,es);
@@ -3186,6 +3186,13 @@ show_resultcache_info(ResultCacheState *rcstate, List *ancestors,
31863186

31873187
si=&rcstate->shared_info->sinstrument[n];
31883188

3189+
/*
3190+
* Skip workers that didn't do any work. We needn't bother checking
3191+
* for cache hits as a miss will always occur before a cache hit.
3192+
*/
3193+
if (si->cache_misses==0)
3194+
continue;
3195+
31893196
if (es->workers_state)
31903197
ExplainOpenWorker(n,es);
31913198

‎src/test/regress/expected/partition_prune.out

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,9 +1958,6 @@ begin
19581958
ln := regexp_replace(ln, 'Workers Launched: \d+', 'Workers Launched: N');
19591959
ln := regexp_replace(ln, 'actual rows=\d+ loops=\d+', 'actual rows=N loops=N');
19601960
ln := regexp_replace(ln, 'Rows Removed by Filter: \d+', 'Rows Removed by Filter: N');
1961-
ln := regexp_replace(ln, 'Hits: \d+', 'Hits: N');
1962-
ln := regexp_replace(ln, 'Misses: \d+', 'Misses: N');
1963-
ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N');
19641961
return next ln;
19651962
end loop;
19661963
end;

‎src/test/regress/expected/resultcache.out

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ $$;
3131
-- Ensure we get a result cache on the inner side of the nested loop
3232
SET enable_hashjoin TO off;
3333
SET enable_bitmapscan TO off;
34-
-- force_parallel_mode = regress can cause some instability in EXPLAIN ANALYZE
35-
-- output, so let's ensure that we turn it off.
36-
SET force_parallel_mode TO off;
3734
SELECT explain_resultcache('
3835
SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1
3936
INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty
@@ -118,7 +115,6 @@ WHERE t2.unique1 < 1200;', true);
118115

119116
RESET enable_mergejoin;
120117
RESET work_mem;
121-
RESET force_parallel_mode;
122118
RESET enable_bitmapscan;
123119
RESET enable_hashjoin;
124120
-- Test parallel plans with Result Cache.

‎src/test/regress/sql/partition_prune.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ begin
464464
ln := regexp_replace(ln,'Workers Launched:\d+','Workers Launched: N');
465465
ln := regexp_replace(ln,'actual rows=\d+ loops=\d+','actual rows=N loops=N');
466466
ln := regexp_replace(ln,'Rows Removed by Filter:\d+','Rows Removed by Filter: N');
467-
ln := regexp_replace(ln,'Hits:\d+','Hits: N');
468-
ln := regexp_replace(ln,'Misses:\d+','Misses: N');
469-
ln := regexp_replace(ln,'Memory Usage:\d+','Memory Usage: N');
470467
return next ln;
471468
end loop;
472469
end;

‎src/test/regress/sql/resultcache.sql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ $$;
3333
-- Ensure we get a result cache on the inner side of the nested loop
3434
SET enable_hashjoin TO off;
3535
SET enable_bitmapscan TO off;
36-
-- force_parallel_mode = regress can cause some instability in EXPLAIN ANALYZE
37-
-- output, so let's ensure that we turn it off.
38-
SET force_parallel_mode TO off;
36+
3937
SELECT explain_resultcache('
4038
SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1
4139
INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty
@@ -69,7 +67,6 @@ INNER JOIN tenk1 t2 ON t1.unique1 = t2.thousand
6967
WHERE t2.unique1 < 1200;', true);
7068
RESET enable_mergejoin;
7169
RESET work_mem;
72-
RESET force_parallel_mode;
7370
RESET enable_bitmapscan;
7471
RESET enable_hashjoin;
7572

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp