On Wed, Mar 3, 2021 at 10:45 PM Dilip Kumar <dilipbal...@gmail.com> wrote: > > On Mon, Mar 1, 2021 at 9:08 AM Greg Nancarrow <gregn4...@gmail.com> wrote: > > > > Posting an updated set of patches that includes Amit Langote's patch > > to the partition tracking scheme... > > (the alternative of adding partitions to the range table needs further > > investigation) > > I was reviewing your latest patch and I have a few comments. > > In patch 0001 > 1. > +static bool > +target_rel_max_parallel_hazard_recurse(Relation rel, > + CmdType command_type, > + max_parallel_hazard_context *context) > +{ > + TupleDesc tupdesc; > + int attnum; > + > + /* Currently only CMD_INSERT is supported */ > + Assert(command_type == CMD_INSERT); > ……. > + /* > + * Column default expressions and check constraints are only applicable to > + * INSERT and UPDATE, but since only parallel INSERT is currently supported, > + * only command_type==CMD_INSERT is checked here. > + */ > + if (command_type == CMD_INSERT) > > If we have an assert at the beginning of the function, then why do we > want to put the if check here? >
Asserts are normally only enabled in a debug-build, so for a release-build that Assert has no effect. The Assert is being used as a sanity-check that the function is only currently getting called for INSERT, because that's all it currently supports. Further code below specifically checks for INSERT because the block contains code that is specific to INSERT (and actually DELETE too, but that is not currently supported - code is commented accordingly). In future, this function will support DELETE and UPDATE, and the Assert serves to alert the developer ASAP that it needs updating to support those. > 2. > In patch 0004, We are still charging the parallel_tuple_cost for each > tuple, are we planning to do something about this? I mean after this > patch tuple will not be transferred through the tuple queue, so we > should not add that cost. > I believe that for Parallel INSERT, cost_modifytable() will set path->path.rows to 0 (unless there is a RETURNING list), so, for example, in cost_gather(), it will not add to the run_cost as "run_cost += parallel_tuple_cost * path->path.rows;" Regards, Greg Nancarrow Fujitsu Australia