Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 92e1583

Browse files
committed
Don't do logical replication of TRUNCATE of zero tables
When due to publication configuration, a TRUNCATE change ends up with zero tables to be published, don't send the message out, just skip it. It's not wrong, but obviously useless overhead.
1 parent e348e7a commit 92e1583

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/backend/replication/pgoutput/pgoutput.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,16 @@ pgoutput_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
407407
maybe_send_schema(ctx, relation, relentry);
408408
}
409409

410-
OutputPluginPrepareWrite(ctx, true);
411-
logicalrep_write_truncate(ctx->out,
412-
nrelids,
413-
relids,
414-
change->data.truncate.cascade,
415-
change->data.truncate.restart_seqs);
416-
OutputPluginWrite(ctx, true);
410+
if (nrelids > 0)
411+
{
412+
OutputPluginPrepareWrite(ctx, true);
413+
logicalrep_write_truncate(ctx->out,
414+
nrelids,
415+
relids,
416+
change->data.truncate.cascade,
417+
change->data.truncate.restart_seqs);
418+
OutputPluginWrite(ctx, true);
419+
}
417420

418421
MemoryContextSwitchTo(old);
419422
MemoryContextReset(data->context);

0 commit comments

Comments
 (0)