Re: [PoC] Reducing planning time when tables have many partitions

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Yuya Watari <watari(dot)yuya(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>, Alena Rybakina <lena(dot)ribackina(at)yandex(dot)ru>, Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, Thom Brown <thom(at)linux(dot)com>, Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Subject: Re: [PoC] Reducing planning time when tables have many partitions
Date: 2025-03-13 04:53:42
Message-ID: CAApHDvon5zQGGw6x5vnpDG7FOB6pZipcf_YzmdQNC+z3wB3mMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 1 Mar 2025 at 23:07, Yuya Watari <watari(dot)yuya(at)gmail(dot)com> wrote:
> The previous patches did not apply to the current master, so I have
> rebased them.

Thank you for continuing to work on this. My apologies for having
completely disappeared from this thread for so long.

Looking at v33-0001, there are a few choices you've made that are not
clear to me:

1) Can you describe the difference between
PlannerInfo.top_parent_relid_array and RelOptInfo.top_parent_relids?
If you've added the PlannerInfo field for performance reasons, then
that needs to be documented. I think the bar for adding another field
to do the same thing should be quite high. The
RelOptInfo.top_parent_relids field already is commented with
"redundant, but handy", so having another field in another struct
that's also redundant leads me to think that some design needs more
thought.

If you need a cheap way to take the same shortcut as you're doing in
setup_eclass_child_member_iterator() with "if
(root->top_parent_relid_array == NULL)", then maybe PlannerInfo should
have a boolean field to record if there are any other member rels

2) I think the naming of setup_eclass_child_member_iterator() and
dispose_eclass_child_member_iterator() is confusing. From the names,
I'd expect these to only be returning em_is_child == true members, but
that's not the case.

3) The header comment for setup_eclass_child_member_iterator() does
not seem concise enough. It claims "so that it can iterate over
EquivalenceMembers in 'ec'.", but what does that mean? The definition
of "EquivalenceMembers in 'ec'" isn't clear. Is that just the class's
ec_members, or also the child members that are stored somewhere else.
Users of this function need to know what they'll get so they know
which members they need to ignore or which they can assume won't be
returned. If you don't document that, then it's quite hard to
determine where the faulty code is when we get bugs. The "relids"
parameter needs to be documented too.

4) add_transformed_child_version sounds like it does some
transformation, but all it does is add the EMs for the given
RelOptInfo to the iterator's list. I don't quite follow what's being
"transformed". Maybe there's a better name?

That's all I have for now.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-03-13 05:19:00 Re: Add an option to skip loading missing publication to avoid logical replication failure
Previous Message Sadeq Dousti 2025-03-13 04:50:58 Re: Add connection active, idle time to pg_stat_activity