pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Amit Kapila <akapila@postgresql.org>
Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
Subject: RE: pgsql: Add a new GUC and a reloption to enable inserts in parallel-mode
Date: Wed, 24 Mar 2021 05:20:27 +0000
Message-ID: <OSAPR01MB29771F59860F7145DF1566F8FE639@OSAPR01MB2977.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <1030301.1616560249@sss.pgh.pa.us>
References: <E1lMiB9-0001c3-SY@gemulon.postgresql.org>
	<CA+TgmoY0GdS7POPWB2nG3yiycNeLz05Mw53NunOjn8f8rZZuxw@mail.gmail.com>
	<558385.1616423602@sss.pgh.pa.us>
	<CAA4eK1+vRWCjMyNJKi+Jk=aOVdH0OuD+ShxTFXchHKH8=yTN9Q@mail.gmail.com>
	<20210323191307.twhewx7vqj2ocglv@alap3.anarazel.de>
	<CA+TgmoazkgAyyMiOy7t2cCRX-VpWUULAOxx+5mb92WCTvkyDmA@mail.gmail.com>
	<1030301.1616560249@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
> Possibly-crazy late-night idea ahead:
> 
> IIUC, we need to know a global property of a partitioning hierarchy:
> is every trigger, CHECK constraint, etc that might be run by an INSERT
> parallel-safe?  What we see here is that reverse-engineering that
> property every time we need to know it is just too expensive, even
> with use of our available caching methods.
> 
> How about a declarative approach instead?  That is, if a user would
> like parallelized inserts into a partitioned table, she must declare
> the table parallel-safe with some suitable annotation.  Then, checking
> the property during DML is next door to free, and instead we have to think
> about whether and how to enforce that the marking is valid during DDL.
> 
> I don't honestly see a real cheap way to enforce such a property.
> For instance, if someone does ALTER FUNCTION to remove a function's
> parallel-safe marking, we can't really run around and verify that the
> function is not used in any CHECK constraint.  (Aside from the cost,
> there would be race conditions.)

I thought of a similar idea as below, which I was most reluctant to adopt.


https://www.postgresql.org/message-id/TYAPR01MB29907AE025B60A1C2CA5F08DFEA70%40TYAPR01MB2990.jpnprd0...
--------------------------------------------------
(3) Record the parallel safety in system catalog
Add a column like relparallel in pg_class that indicates the parallel safety of the relation.  planner just checks the value instead of doing heavy work for every SQL statement.  That column's value is modified whenever a relation alteration is made that affects the parallel safety, such as adding a domain column and CHECK constraint.  In case of a partitioned relation, the parallel safety attributes of all its descendant relations are merged.  For example, if a partition becomes parallel-unsafe, the ascendant partitioned tables also become parallel-unsafe.



But... developing such code would be burdonsome and bug-prone?
--------------------------------------------------


> But maybe we don't have to enforce it exactly.  It could be on the
> user's head that the marking is accurate.  We could prevent any
> really bad misbehavior by having parallel workers error out if they
> see they've been asked to execute a non-parallel-safe function.

I'm wondering if we can do so as I mentioned yesterday; the parallel worker delegates the work to the parallel leader when the target relation or related functions is not parallel-safe.


	Regards
Takayuki 	Tsunakawa
						






view thread (37+ messages)  latest in thread

Message-ID: <OSAPR01MB29771F59860F7145DF1566F8FE639@OSAPR01MB2977.jpnprd01.prod.outlook.com>
Permalink:  ../OSAPR01MB29771F59860F7145DF1566F8FE639@OSAPR01MB2977.jpnprd01.prod.outlook.com/
Also on:    postgresql.org/message-id/OSAPR01MB29771F59860F7145DF1566F8FE639@OSAPR01MB2977.jpnprd01.prod.outlook.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tsunakawa.takay@fujitsu.com, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, andres@anarazel.de, amit.kapila16@gmail.com, akapila@postgresql.org
  Subject: Re: pgsql: Add a new GUC and a reloption to enable inserts in parallel-mode
  In-Reply-To: <OSAPR01MB29771F59860F7145DF1566F8FE639@OSAPR01MB2977.jpnprd01.prod.outlook.com>
  References: <E1lMiB9-0001c3-SY@gemulon.postgresql.org> <CA+TgmoY0GdS7POPWB2nG3yiycNeLz05Mw53NunOjn8f8rZZuxw@mail.gmail.com> <558385.1616423602@sss.pgh.pa.us> <CAA4eK1+vRWCjMyNJKi+Jk=aOVdH0OuD+ShxTFXchHKH8=yTN9Q@mail.gmail.com> <20210323191307.twhewx7vqj2ocglv@alap3.anarazel.de> <CA+TgmoazkgAyyMiOy7t2cCRX-VpWUULAOxx+5mb92WCTvkyDmA@mail.gmail.com> <1030301.1616560249@sss.pgh.pa.us> <OSAPR01MB29771F59860F7145DF1566F8FE639@OSAPR01MB2977.jpnprd01.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox