Re: Parallel INSERT (INTO ... SELECT ...)

From: Greg Nancarrow <gregn4422(at)gmail(dot)com>
To: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>
Subject: Re: Parallel INSERT (INTO ... SELECT ...)
Date: 2021-02-22 12:40:20
Message-ID: CAJcOf-ck9GGP09AgOuOWw-CVTGLXr0S4Knem=uOtpottgizE8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 22, 2021 at 6:25 PM houzj(dot)fnst(at)fujitsu(dot)com
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> Hi
>
> (I may be wrong here)
> I noticed that the patch does not have check for partial index(index predicate).
> It seems parallel index build will check it like the following:
> ----------
> /*
> * Determine if it's safe to proceed.
> *
> * Currently, parallel workers can't access the leader's temporary tables.
> * Furthermore, any index predicate or index expressions must be parallel
> * safe.
> */
> if (heap->rd_rel->relpersistence == RELPERSISTENCE_TEMP ||
> !is_parallel_safe(root, (Node *) RelationGetIndexExpressions(index)) ||
> !is_parallel_safe(root, (Node *) RelationGetIndexPredicate(index)))
> ----------
>
> Should we do parallel safety check for it ?
>

Thanks, it looks like you're right, it is missing (and there's no test for it).
I can add a fix to the index-checking code, something like:

+ if (!found_max_hazard)
+ {
+ ii_Predicate = RelationGetIndexPredicate(index_rel);
+ if (ii_Predicate != NIL)
+ {
+ if (max_parallel_hazard_walker((Node *)ii_Predicate, context))
+ {
+ found_max_hazard = true;
+ }
+ }
+ }

Also will need a bit of renaming of that function.
I'll include this in the next patch update.

Regards,
Greg Nancarrow
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2021-02-22 13:31:13 Re: Support for NSS as a libpq TLS backend
Previous Message Euler Taveira 2021-02-22 12:38:36 Re: [PATCH] pg_hba.conf error messages for logical replication connections