Re: simplifying foreign key/RI checks

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Keisuke Kuroda <keisuke(dot)kuroda(dot)3862(at)gmail(dot)com>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: simplifying foreign key/RI checks
Date: 2021-01-25 10:01:44
Message-ID: CA+HiwqE4xN5fqeKjckxFpFiCd_LLzbwsjHumhE=t_yNkMQa+pg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kuroda-san,

On Mon, Jan 25, 2021 at 6:06 PM Keisuke Kuroda
<keisuke(dot)kuroda(dot)3862(at)gmail(dot)com> wrote:
> Hi, Amit-san,
>
> Nice patch. I have confirmed that this solves the problem in [1] with
> INSERT/UPDATE.

Thanks for testing.

> HEAD + patch
> name | bytes | pg_size_pretty
> ------------------+-------+----------------
> CachedPlanQuery | 10280 | 10 kB
> CachedPlanSource | 14616 | 14 kB
> CachedPlan | 13168 | 13 kB ★ 710MB -> 13kB
> (3 rows)

If you only tested insert/update on the referencing table, I would've
expected to see nothing in the result of that query, because the patch
eliminates all use of SPI in that case. I suspect the CachedPlan*
memory contexts you are seeing belong to some early activity in the
session. So if you try the insert/update in a freshly started
session, you would see 0 rows in the result of that query.

> > > This patch completely sidesteps the DELETE case, which has more insidious performance implications, but is also far less common, and whose solution will likely be very different.
> >
> > Yeah, we should continue looking into the ways to make referenced-side
> > RI checks be less bloated.
>
> However, as already mentioned, the problem of memory bloat on DELETE remains.
> This can be solved by the patch in [1], but I think it is too much to apply
> this patch only for DELETE. What do you think?
>
> [1] https://www.postgresql.org/message-id/flat/cab4b85d-9292-967d-adf2-be0d803c3e23%40nttcom.co.jp_1

Hmm, the patch tries to solve a general problem that SPI plans are not
being shared among partitions whereas they should be. So I don't
think that it's necessarily specific to DELETE. Until we have a
solution like the patch on this thread for DELETE, it seems fine to
consider the other patch as a stopgap solution.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-01-25 10:08:43 Re: Identify missing publications from publisher while create/alter subscription.
Previous Message Fujii Masao 2021-01-25 09:47:05 Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit