Re: More efficient RI checks - take 2

From: Antonin Houska <ah(at)cybertec(dot)at>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: More efficient RI checks - take 2
Date: 2020-04-20 13:56:35
Message-ID: 8011.1587390995@antos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

>> st 8. 4. 2020 v 18:36 odesílatel Antonin Houska <ah(at)cybertec(dot)at> napsal:
>
>> Some performance comparisons are below. (Besides the execution time, please
>> note the difference in the number of trigger function executions.) In general,
>> the checks are significantly faster if there are many rows to process, and a
>> bit slower when we only need to check a single row. However I'm not sure about
>> the accuracy if only a single row is measured (if a single row check is
>> performed several times, the execution time appears to fluctuate).
>
> It is hard task to choose good strategy for immediate constraints, but for
> deferred constraints you know how much rows should be checked, and then you
> can choose better strategy.
>
> Is possible to use estimation for choosing method of RI checks?

The exact number of rows ("batch size") is always known before the query is
executed. So one problem to solve is that, when only one row is affected, we
need to convince the planner that the "transient table" really contains a
single row. Otherwise it can, for example, produce a hash join where the hash
eventually contains a single row.

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-04-20 14:12:11 Re: Allow pg_read_all_stats to read pg_stat_progress_*
Previous Message Masahiko Sawada 2020-04-20 13:24:40 Re: Problem with logical replication