Re: Remove duplicate table scan in logical apply worker and code refactoring
От | Kirill Reshke |
---|---|
Тема | Re: Remove duplicate table scan in logical apply worker and code refactoring |
Дата | |
Msg-id | CALdSSPga5LX5OEKnYpiMHm4HbkJ-sY-DjrLU38ctcz_P19qV+Q@mail.gmail.com обсуждение исходный текст |
Ответ на | Remove duplicate table scan in logical apply worker and code refactoring ("Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>) |
Ответы |
Re: Remove duplicate table scan in logical apply worker and code refactoring
Re: Remove duplicate table scan in logical apply worker and code refactoring |
Список | pgsql-hackers |
Hi! > When reviewing the code in logical/worker.c, I noticed that when applying a > cross-partition update action, it scans the old partition twice. Nice catch! > -/* > - * Workhorse for apply_handle_update() > - * relinfo is for the relation we're actually updating in > - * (could be a child partition of edata->targetRelInfo) > - */ > -static void > -apply_handle_update_internal(ApplyExecutionData *edata, > - ResultRelInfo *relinfo, > - TupleTableSlot *remoteslot, > - LogicalRepTupleData *newtup, > - Oid localindexoid) > -{ What's the necessity of this change? Can we modify a function in-place instead of removing and rewriting it in the same file? This will reduce diff, making patch a bit more clear. > +/* > + * If the tuple to be modified could not be found, a log message is emitted. > + */ > +static void > +report_tuple_not_found(CmdType cmd, Relation targetrel, bool is_partition) > +{ > + Assert(cmd == CMD_UPDATE || cmd == CMD_DELETE); > + > + /* XXX should this be promoted to ereport(LOG) perhaps? */ > + elog(DEBUG1, > + "logical replication did not find row to be %s in replication target relation%s \"%s\"", > + cmd == CMD_UPDATE ? "updated" : "deleted", > + is_partition ? "'s partition" : "", > + RelationGetRelationName(targetrel)); > +} Encapsulating report logic inside function is ok, but double ternary expression is a bit out of line. I do not see similar places within PostgreSQL, so it probably violates code style.
В списке pgsql-hackers по дате отправления: