>CREATE TABLE t1 (a text); >CREATE TABLE t2 (a text); >-- make the text a little large by adding 100000000000 >INSERT INTO t1 SELECT (100000000000+i%1000)::text FROM >generate_series(0,10000000) i;
>-- make the text a little large by adding 100000000000 >INSERT INTO t2 SELECT (100000000000+i%10000)::text FROM >generate_series(0,10000000) i; >-- to simplify the explain plan, not strictly necessary >SET max_parallel_workers_per_gather TO 0; >-- these two are necessary so that the problem is triggered >-- these are helpful to use Merge join and avoid materialization >SET enable_hashjoin TO false; >SET enable_material TO false; >-- the join is on a TEXT column >-- when the join is on INT column with a similar setup, I do not observe >this problem >SELECT count(*) FROM t1 JOIN t2 USING (a); >``` >The explain output for the query like the following: >``` >explain SELECT count(*) FROM t1 JOIN t2 USING (a); I run your test here with a fix attached. Can you retake your test with the patch attached? regards, Ranier Vilela
fix_possible_memory_leak_merge_join_sort.patch
Description: Binary data