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

Lines changed: 10 additions & 7 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy