diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 579b8075b5..3f66e43b9a 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -7877,12 +7877,6 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
 	{
 		List	   *children;
 
-		/*
-		 * Make previous addition visible, in case we process the same
-		 * relation again while chasing down multiple inheritance trees.
-		 */
-		CommandCounterIncrement();
-
 		children = find_inheritance_children(RelationGetRelid(rel),
 											 lockmode);
 
@@ -7890,6 +7884,8 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
 		{
 			Relation	childrel = table_open(childoid, NoLock);
 
+			CommandCounterIncrement();
+
 			ATExecSetNotNull(wqueue, childrel, conName, colName,
 							 recurse, true, lockmode);
 			table_close(childrel, NoLock);
