public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andy Fan <[email protected]>
To: Andrey Lepikhov <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: A new strategy for pull-up correlated ANY_SUBLINK
Date: Wed, 2 Nov 2022 13:34:54 +0800
Message-ID: <CAKU4AWo27rPRZVUQ7UGPNd_MDRUH9mmEoC4jY3+mU_yC5VwYvw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAKU4AWoZksNZ4VR-fLTdwmiR91WU8qViDBNQKNwY=7iyo+uV0w@mail.gmail.com>
	<[email protected]>

Hi Andrey:


> > In this patch we distinguish the above case and try to pull-up it within
> > one step if it is helpful, It looks to me that what we need to do is just
> > transform it to EXIST-SUBLINK.
> Maybe code [1] would be useful for your purposes/tests.
>

Looks like we are resolving the same problem, IIUC,  great that more
people are interested in it!

We implemented flattening of correlated subqueries for simple N-J case,


I went through the code,  and it looks like you tried to do the pull-up by
yourself, which would have many troubles to think about.  but I just
transformed
it into EXIST sublink after I distinguish it as the case I can improve.
> The only change is transforming the format of SUBLINK, so outer-join /
> pull-up as semi-join is unrelated, so the correctness should not be an
> issue.

That is just a difference, no matter which one is better.

but found out that in some cases the flattening isn't obvious the best
> solution - we haven't info about cardinality/cost estimations and can do
> worse.

I guess, for more complex flattening procedure (with aggregate function
> in a targetlist of correlated subquery) situation can be even worse.
> Maybe your idea has such corner cases too ?
>

In my case, since aggregate function can't be handled by
covert_EXISTS_sublink_to_join, so it is not the target I want to optimize in
this patch.  More testing/review on my method would be pretty appreciated.
but I'm not insisting on my method at all.  Link [2] might be useful as
well.

[2]
https://www.postgresql.org/message-id/CAKU4AWpi9oztiomUQt4JCxXEr6EaQ2thY-7JYDm6c9he0A7oCA%40mail.gma...


-- 
Best Regards
Andy Fan


view thread (30+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: A new strategy for pull-up correlated ANY_SUBLINK
  In-Reply-To: <CAKU4AWo27rPRZVUQ7UGPNd_MDRUH9mmEoC4jY3+mU_yC5VwYvw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox