From 6c684ac80914a388a942b435d0e78ab327564b6c Mon Sep 17 00:00:00 2001
From: Euler Taveira <euler.taveira@enterprisedb.com>
Date: Sun, 31 Jan 2021 20:48:43 -0300
Subject: [PATCH 7/7] Measure row filter overhead

---
 src/backend/replication/pgoutput/pgoutput.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 17a728c0bf..ebd45c1c84 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -542,6 +542,8 @@ pgoutput_row_filter(Relation relation, HeapTuple oldtuple, HeapTuple newtuple, L
 	MemoryContext oldcxt;
 	ListCell   *lc;
 	bool		result = true;
+	instr_time	start_time;
+	instr_time	end_time;
 
 	/* Bail out if there is no row filter */
 	if (list_length(rowfilter) == 0)
@@ -549,6 +551,8 @@ pgoutput_row_filter(Relation relation, HeapTuple oldtuple, HeapTuple newtuple, L
 
 	elog(DEBUG1, "table %s has row filter", get_rel_name(relation->rd_id));
 
+	INSTR_TIME_SET_CURRENT(start_time);
+
 	tupdesc = RelationGetDescr(relation);
 
 	estate = create_estate_for_relation(relation);
@@ -606,6 +610,11 @@ pgoutput_row_filter(Relation relation, HeapTuple oldtuple, HeapTuple newtuple, L
 	ResetExprContext(ecxt);
 	FreeExecutorState(estate);
 
+	INSTR_TIME_SET_CURRENT(end_time);
+	INSTR_TIME_SUBTRACT(end_time, start_time);
+
+	elog(DEBUG2, "row filter time: %0.3f us", INSTR_TIME_GET_DOUBLE(end_time) * 1e6);
+
 	return result;
 }
 
-- 
2.20.1

