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

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

Hello,

On Thu, May 16, 2024 at 11:44 AM Yuya Watari <watari(dot)yuya(at)gmail(dot)com> wrote:
> I'm sorry it will take some time to solve
> this conflict, but I will post a new version when it is fixed.

The previous patches no longer apply to the master, so I rebased them.
I'm sorry for the delay.

I will summarize the patches again.

1. v25-0001
This patch is one of the main parts of my optimization. Traditionally,
EquivalenceClass has both parent and child members. However, this
leads to high iteration costs when there are many child partitions. In
v25-0001, EquivalenceClasses no longer have child members. If we need
to iterate over child EquivalenceMembers, we use the
EquivalenceChildMemberIterator and access the children through the
iterator. For more details, see [1] (note that there are some design
changes from [1]).

2. v25-0002
This patch was made in the previous work with David. Like
EquivalenceClass, there are many RestrictInfos in highly partitioned
cases. This patch introduces an indexing mechanism to speed up
searches for RestrictInfos.

3. v25-0003
v25-0002 adds its indexes to RangeTblEntry, but this is not a good
idea. RelOptInfo is the best place. This problem is a workaround
because some RelOptInfos can be NULL, so we cannot store indexes to
such RelOptInfos. v25-0003 moves the indexes from RangeTblEntry to
PlannerInfo. This is still a workaround, and I think it should be
reconsidered.

4. v25-0004
After our changes, add_eq_member() no longer creates and adds child
EquivalenceMembers. This commit renames it to add_parent_eq_member()
to clarify that it only creates parent members, and that we need to
use make_eq_member() to handle child EquivalenceMembers.

5. v25-0005
This commit resolves a conflict with commit 66c0185 [2], which adds
add_setop_child_rel_equivalences(). As I mentioned in the previous
email [3], this function creates child EquivalenceMembers by calling
add_eq_member(). This commit adjusts our optimization so that it can
handle such child members.

[1] https://www.postgresql.org/message-id/CAJ2pMkZk-Nr%3DyCKrGfGLu35gK-D179QPyxaqtJMUkO86y1NmSA%40mail.gmail.com
[2] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=66c0185a3
[3] https://www.postgresql.org/message-id/CAJ2pMkZt6r94NUYm-F77FYahjgnMrY4CLHGAD7HxYZxGVwCaow%40mail.gmail.com

--
Best regards,
Yuya Watari

Attachment Content-Type Size
v25-0001-Speed-up-searches-for-child-EquivalenceMembers.patch application/octet-stream 58.8 KB
v25-0002-Introduce-indexes-for-RestrictInfo.patch application/octet-stream 42.9 KB
v25-0003-Move-EquivalenceClass-indexes-to-PlannerInfo.patch application/octet-stream 14.4 KB
v25-0004-Rename-add_eq_member-to-add_parent_eq_member.patch application/octet-stream 5.2 KB
v25-0005-Resolve-conflict-with-commit-66c0185.patch application/octet-stream 6.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2024-08-29 05:36:40 RE: Collect statistics about conflicts in logical replication
Previous Message Michael Paquier 2024-08-29 05:11:22 Re: Removing log_cnt from pg_sequence_read_tuple()