diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 9313d2b01e..de4a6f7baa 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -88,6 +88,7 @@
 
 #include <unistd.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 
 #include "access/detoast.h"
 #include "access/heapam.h"
@@ -1515,6 +1516,9 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 	bool		found;
 	dlist_mutable_iter iter;
 	Size		mem_freed = 0;
+	ListCell *cell;
+	struct timeval stop, start;
+	gettimeofday(&start, NULL);
 
 	/* cleanup subtransactions & their changes */
 	dlist_foreach_modify(iter, &txn->subtxns)
@@ -1614,6 +1618,9 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 	if (rbtxn_is_serialized(txn))
 		ReorderBufferRestoreCleanup(rb, txn);
 
+	gettimeofday(&stop, NULL);
+	elog(LOG, "Time to Cleanup txn: %d is : %lu", txn->xid, (stop.tv_sec - start.tv_sec) * 1000000 + stop.tv_usec - start.tv_usec);
+
 	/* deallocate */
 	ReorderBufferReturnTXN(rb, txn);
 }
