diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 56943f2..d331adf 100644
*** a/src/backend/utils/adt/selfuncs.c
--- b/src/backend/utils/adt/selfuncs.c
*************** eqjoinsel_semi(Oid operator,
*** 2511,2520 ****
  	 * We can apply this clamping both with respect to the base relation from
  	 * which the join variable comes (if there is just one), and to the
  	 * immediate inner input relation of the current join.
  	 */
  	if (vardata2->rel)
! 		nd2 = Min(nd2, vardata2->rel->rows);
! 	nd2 = Min(nd2, inner_rel->rows);
  
  	if (HeapTupleIsValid(vardata1->statsTuple))
  	{
--- 2511,2532 ----
  	 * We can apply this clamping both with respect to the base relation from
  	 * which the join variable comes (if there is just one), and to the
  	 * immediate inner input relation of the current join.
+ 	 *
+ 	 * If we clamp, we can consider that nd2 is not a bogus default estimate.
  	 */
  	if (vardata2->rel)
! 	{
! 		if (nd2 >= vardata2->rel->rows)
! 		{
! 			nd2 = vardata2->rel->rows;
! 			isdefault2 = false;
! 		}
! 	}
! 	if (nd2 >= inner_rel->rows)
! 	{
! 		nd2 = inner_rel->rows;
! 		isdefault2 = false;
! 	}
  
  	if (HeapTupleIsValid(vardata1->statsTuple))
  	{
