From: | Andy Fan <zhihuifan1213(at)163(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: why memoize is not used for correlated subquery |
Date: | 2024-05-28 09:47:17 |
Message-ID: | 87cyp6s1qw.fsf@163.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> I imagined making this work by delaying the plan creation for
> subqueries until the same time as create_plan() for the outer query.
Do you mean sublinks rather than subqueries? if so, we can get another
benefit I want very much.
explain (costs off) select * from t1 where t1.a = 1
and exists (select 1 from t2 where t2.a = t1.a and random() > 0);
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on t1
Filter: ((a = 1) AND EXISTS(SubPlan 1))
SubPlan 1
-> Seq Scan on t2
Filter: ((a = t1.a) AND (random() > '0'::double precision))
As for now, when we are planing the sublinks, we don't know t1.a = 1
which may lost some optimization chance. Considering the t2.a is a
partition key of t2, this would yield some big improvement for planning
a big number of partitioned table.
--
Best Regards
Andy Fan
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2024-05-28 09:56:26 | Re: ON ERROR in json_query and the like |
Previous Message | Andy Fan | 2024-05-28 09:29:48 | Re: Parallel CREATE INDEX for GIN indexes |