Re: Huge memory consumption on partitioned table with FKs

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: 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: 2020-12-04 06:32:32
Message-ID: CA+HiwqGrr2YOO6voBM6m_OAc9w-WMxe1gOuQ-UyDPin6zJtyZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 4, 2020 at 2:48 PM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
> At Fri, 4 Dec 2020 12:00:09 +0900, Keisuke Kuroda <keisuke(dot)kuroda(dot)3862(at)gmail(dot)com> wrote in
> > Hi Amit,
> >
> > > I have attached a patch in which I've tried to merge the ideas from
> > > both my patch and Kuroda-san's. I liked that his patch added
> > > conparentid to RI_ConstraintInfo because that saves a needless
> > > syscache lookup for constraints that don't have a parent. I've kept
> > > my idea to compute the root constraint id only once in
> > > ri_LoadConstraint(), not on every invocation of ri_BuildQueryKey().
> > > Kuroda-san, anything you'd like to add to that?
> >
> > Thank you for the merge! It looks good to me.
> > I think a fix for InvalidateConstraintCacheCallBack() is also good.
> >
> > I also confirmed that the patch passed the make check-world.
>
> It's fine that constraint_rood_id overrides constraint_id, but how
> about that constraint_root_id stores constraint_id if it is not a
> partition? That change makes the patch a bit simpler.

My patch was like that before posting to this thread, but keeping
constraint_id and constraint_root_id separate looked better for
documenting the partitioning case as working differently from the
regular table case. I guess a comment in ri_BuildQueryKey is enough
for that though and it's not like we're using constraint_root_id in
any other place to make matters confusing, so I changed it as you
suggest. Updated patch attached.

--
Amit Langote
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
v3-0001-ri_triggers.c-Use-root-constraint-OID-as-key-to-r.patch application/octet-stream 6.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2020-12-04 06:37:33 Re: Is it useful to record whether plans are generic or custom?
Previous Message Bharath Rupireddy 2020-12-04 06:29:51 Re: A new function to wait for the backend exit after termination