pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Get rid of runtime handling of AlternativeSubPlan?
Date: Mon, 31 Aug 2020 11:41:46 -0400
Message-ID: <3968496.1598888506@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvqhcEab0aJ29C+yznHiUHNqoKvTOL+sz0p3a1SNon4ntg@mail.gmail.com>
References: <1992952.1592785225@sss.pgh.pa.us>
	<3740825.1598743596@sss.pgh.pa.us>
	<CAApHDvqhcEab0aJ29C+yznHiUHNqoKvTOL+sz0p3a1SNon4ntg@mail.gmail.com>

David Rowley <dgrowleyml@gmail.com> writes:
> Do you feel that the choice to create_plan() on the subplan before
> planning the outer query is still a good one?  ISTM that that was
> required when the AlternativeSubplan decision was made during
> execution, since we, of course, need a plan to execute. If the
> decision is now being made in the planner then is it not better to
> delay the create_plan() until later in planning?

Hm.  That's well outside the scope I had in mind for this patch.
In principle, you're right that we could postpone final planning
of the subquery till later; but I fear it'd require quite a lot
of refactoring to make it work that way.  There's a lot of rather
subtle timing dependencies in the processing done by createplan.c
and setrefs.c, so I think this might be a lot more painful than
it seems at first glance.  And we'd only gain anything in cases that
use AlternativeSubPlan, which is a minority of subplans, so on the
whole I rather doubt it's worth the trouble.

One inefficiency I see that we could probably get rid of is
where make_subplan() is doing

            /* Now we can check if it'll fit in hash_mem */
            /* XXX can we check this at the Path stage? */
            if (subplan_is_hashable(plan))
            {

The only inputs subplan_is_hashable needs are the predicted rowcount
and output width, which surely we could get from the Path.  So we
could save doing create_plan() when we decide the subquery output is
too big to hash.  OTOH, that's probably a pretty small minority of
use-cases, so it might not be worth troubling over.

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <3968496.1598888506@sss.pgh.pa.us>
Permalink:  ../3968496.1598888506@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3968496.1598888506@sss.pgh.pa.us

 · 

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: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Get rid of runtime handling of AlternativeSubPlan?
  In-Reply-To: <3968496.1598888506@sss.pgh.pa.us>

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

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