enable_memoize and max_parallel_workers_per_gather problem or bug?

286 views Asked by At

using Postgresql 15.2, I tried any kind of query that join a CTE with a table:

with t as (select t.day from calendar where idtime between 20230101 and 20230224)
select idcell, sum (tmean)
from   weather w join t on w.day = t.day
group by idcell

entire tables calendar and the partitioned table wheater have been prewarmed in shared buffers.

Now if I set:

enable_memoize = on; max_parallel_workers_per_gather = 0;

Query has been executed in 1 seconds

enable_memoize = off; max_parallel_workers_per_gather = 20;

Query has been executed in 39 seconds, max workers used 6

enable_memoize = on; max_parallel_workers_per_gather = 2 or whatever > 0;

Query goes in error with:

ERROR: could not find memoization table entry CONTEXT: parallel worker

Could be a bug in PostgreSQL planner ?

1

There are 1 answers

0
Tomasz Malec On

This is bug related to feature enabled by default in PG - https://www.postgresql.org/docs/current/runtime-config-query.html

It can be disabled for connection by: SET enable_memoize = off;

I have the same issue when I left join two tables when column used in join is used in where and both objects have index on this column. Should be efficient and everything but this exact feature have and issue