Re: Parallel Inserts in CREATE TABLE AS

From: Luc Vlaming <luc(at)swarm64(dot)com>
To: "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Parallel Inserts in CREATE TABLE AS
Date: 2021-01-04 12:14:41
Message-ID: e47d503a-d019-dde2-fe18-47a01a68b1b0@swarm64.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04-01-2021 12:16, Hou, Zhijie wrote:
> Hi
>
>> ================
>> wrt v18-0002....patch:
>>
>> It looks like this introduces a state machine that goes like:
>> - starts at CTAS_PARALLEL_INS_UNDEF
>> - possibly moves to CTAS_PARALLEL_INS_SELECT
>> - CTAS_PARALLEL_INS_TUP_COST_CAN_IGN can be added
>> - if both were added at some stage, we can go to
>> CTAS_PARALLEL_INS_TUP_COST_IGNORED and ignore the costs
>>
>> what i'm wondering is why you opted to put logic around
>> generate_useful_gather_paths and in cost_gather when to me it seems more
>> logical to put it in create_gather_path? i'm probably missing something
>> there?
>
> IMO, The reason is we want to make sure we only ignore the cost when Gather is the top node.
> And it seems the generate_useful_gather_paths called in apply_scanjoin_target_to_paths is the right place which can only create top node Gather.
> So we change the flag in apply_scanjoin_target_to_paths around generate_useful_gather_paths to identify the top node.
>
>
> Best regards,
> houzj
>
>

Hi,

I was wondering actually if we need the state machine. Reason is that as
AFAICS the code could be placed in create_gather_path, where you can
also check if it is a top gather node, whether the dest receiver is the
right type, etc? To me that seems like a nicer solution as its makes
that all logic that decides whether or not a parallel CTAS is valid is
in a single place instead of distributed over various places.

Kind regards,
Luc

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2021-01-04 12:42:27 Re: pg_rewind restore_command issue in PG12
Previous Message Heikki Linnakangas 2021-01-04 12:08:18 Re: Deleting older versions in unique indexes to avoid page splits