diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index 4eae85f..ef588d1 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -306,9 +306,12 @@ ExecHashJoin(HashJoinState *node)
 					}
 
 					/*
-					 * When the inner side is unique or we're performing a
-					 * semijoin, we'll consider returning the first match, but
-					 * after that we're done with this outer tuple.
+					 * In the event that the inner side has been detected to be
+					 * unique, as an optimization we can skip searching for any
+					 * subsequent matching inner tuples, as none will exist.
+					 * For semijoins unique_inner will always be true, although
+					 * in this case we don't match another inner tuple as this
+					 * is the required semi join behavior.
 					 */
 					if (node->js.unique_inner)
 						node->hj_JoinState = HJ_NEED_NEW_OUTER;
diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c
index 2cd532d..0445d66 100644
--- a/src/backend/executor/nodeMergejoin.c
+++ b/src/backend/executor/nodeMergejoin.c
@@ -840,9 +840,12 @@ ExecMergeJoin(MergeJoinState *node)
 					}
 
 					/*
-					 * When the inner side is unique or we're performing a
-					 * semijoin, we'll consider returning the first match, but
-					 * after that we're done with this outer tuple.
+					 * In the event that the inner side has been detected to be
+					 * unique, as an optimization we can skip searching for any
+					 * subsequent matching inner tuples, as none will exist.
+					 * For semijoins unique_inner will always be true, although
+					 * in this case we don't match another inner tuple as this
+					 * is the required semi join behavior.
 					 */
 					if (node->js.unique_inner)
 						node->mj_JoinState = EXEC_MJ_NEXTOUTER;
diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c
index 6f0297d..cfb9c9d 100644
--- a/src/backend/executor/nodeNestloop.c
+++ b/src/backend/executor/nodeNestloop.c
@@ -247,9 +247,12 @@ ExecNestLoop(NestLoopState *node)
 			}
 
 			/*
-			 * When the inner side is unique or we're performing a semijoin,
-			 * we'll consider returning the first match, but after that we're
-			 * done with this outer tuple.
+			 * In the event that the inner side has been detected to be unique,
+			 * as an optimization we can skip searching for any subsequent
+			 * matching inner tuples, as none will exist. For semijoins
+			 * unique_inner will always be true, although in this case we don't
+			 * match another inner tuple as this is the required semi join
+			 * behavior.
 			 */
 			if (node->js.unique_inner)
 				node->nl_NeedNewOuter = true;
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index d74e496..13e31a4 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -85,7 +85,7 @@ add_paths_to_joinrel(PlannerInfo *root,
 	ListCell   *lc;
 	bool		unique_inner;
 
-	/* left joins were already been analyzed for uniqueness in mark_unique_joins() */
+	/* left joins were already analyzed for uniqueness in mark_unique_joins() */
 	if (jointype == JOIN_LEFT)
 		unique_inner = sjinfo->is_unique_join;
 	else if (jointype == JOIN_INNER &&
diff --git a/src/backend/optimizer/plan/analyzejoins.c b/src/backend/optimizer/plan/analyzejoins.c
index f583477..2262183 100644
--- a/src/backend/optimizer/plan/analyzejoins.c
+++ b/src/backend/optimizer/plan/analyzejoins.c
@@ -42,8 +42,8 @@ static Oid	distinct_col_search(int colno, List *colnos, List *opids);
 
 /*
  * mark_unique_joins
-		Analyze joins in order to determine if their inner side is unique based
-		on the join condition.
+ *		Analyze joins in order to determine if their inner side is unique based
+ *		on the join condition.
  */
 void
 mark_unique_joins(PlannerInfo *root, List *joinlist)
@@ -617,6 +617,7 @@ rel_is_distinct_for(PlannerInfo *root, RelOptInfo *rel, List *clause_list)
 	}
 	return false; /* can't prove rel to be distinct over clause_list */
 }
+
 /*
  * rel_supports_distinctness
  *		Returns true if rel has some properties which can prove the relation
