Re: Huge memory consumption on partitioned table with FKs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, keisuke kuroda <keisuke(dot)kuroda(dot)3862(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Tatsuro Yamada <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, tatsuhito(dot)kasahara(dot)rd(at)hco(dot)ntt(dot)co(dot)jp
Subject: Re: Huge memory consumption on partitioned table with FKs
Date: 2021-03-04 21:00:36
Message-ID: 1412267.1614891636@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Amit Langote <amitlangote09(at)gmail(dot)com> writes:
> Updated patch attached.

This claim seems false on its face:

> All child constraints of a given foreign key constraint can use the
> same RI query and the resulting plan, that is, no need to create as
> many copies of the query and the plan as there are partitions, as
> happens now due to the child constraint OID being used in the key
> for ri_query_cache.

What if the child tables don't have the same physical column numbers
as the parent? The comment claiming that it's okay if riinfo->fk_attnums
doesn't match seems quite off point, because the query plan is still
going to need to use the correct column numbers. Even if column numbers
are the same, the plan would also contain table and index OIDs that could
only be right for one partition.

I could imagine translating a parent plan to apply to a child instead of
building it from scratch, but that would take a lot of code we don't have
(there's no rewriteHandler infrastructure for plan nodes).

Maybe I'm missing something, because I see that the cfbot claims
this is passing, and I'd sure like to think that our test coverage
is not so thin that it'd fail to detect probing the wrong partition
for foreign key matches. But that's what it looks like this patch
will do.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Wieck 2021-03-04 21:01:15 Re: PROXY protocol support
Previous Message Heikki Linnakangas 2021-03-04 20:55:54 Re: Removing support for COPY FROM STDIN in protocol version 2