*** a/doc/src/sgml/config.sgml
--- b/doc/src/sgml/config.sgml
***************
*** 2288,2296 **** SELECT * FROM parent WHERE key = 2400;
         </para>
  
         <para>
!         By default, this variable is set the same as
!         <varname>from_collapse_limit</varname>, which is appropriate
!         for most uses. Setting it to 1 prevents any reordering of
          explicit <literal>JOIN</>s. Thus, the explicit join order
          specified in the query will be the actual order in which the
          relations are joined. The query planner does not always choose
--- 2288,2295 ----
         </para>
  
         <para>
!         By default, this variable is set to <literal>0</>, which always
!         allows rewriting.  Setting it to 1 prevents any reordering of
          explicit <literal>JOIN</>s. Thus, the explicit join order
          specified in the query will be the actual order in which the
          relations are joined. The query planner does not always choose
*** a/src/backend/optimizer/plan/initsplan.c
--- b/src/backend/optimizer/plan/initsplan.c
***************
*** 477,483 **** deconstruct_recurse(PlannerInfo *root, Node *jtnode, bool below_outer_join,
  			/* force the join order exactly at this node */
  			joinlist = list_make1(list_make2(leftjoinlist, rightjoinlist));
  		}
! 		else if (list_length(leftjoinlist) + list_length(rightjoinlist) <=
  				 join_collapse_limit)
  		{
  			/* OK to combine subproblems */
--- 477,484 ----
  			/* force the join order exactly at this node */
  			joinlist = list_make1(list_make2(leftjoinlist, rightjoinlist));
  		}
! 		else if (join_collapse_limit == 0
! 				 || list_length(leftjoinlist) + list_length(rightjoinlist) <=
  				 join_collapse_limit)
  		{
  			/* OK to combine subproblems */
*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
***************
*** 1275,1284 **** static struct config_int ConfigureNamesInt[] =
  						 "constructs are not flattened."),
  			gettext_noop("The planner will flatten explicit JOIN "
  						 "constructs into lists of FROM items whenever a "
! 						 "list of no more than this many items would result.")
  		},
  		&join_collapse_limit,
! 		8, 1, INT_MAX, NULL, NULL
  	},
  	{
  		{"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
--- 1275,1285 ----
  						 "constructs are not flattened."),
  			gettext_noop("The planner will flatten explicit JOIN "
  						 "constructs into lists of FROM items whenever a "
! 						 "list of no more than this many items would result. "
! 						 "Zero indicates no limit.")
  		},
  		&join_collapse_limit,
! 		0, 0, INT_MAX, NULL, NULL
  	},
  	{
  		{"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
*** a/src/backend/utils/misc/postgresql.conf.sample
--- b/src/backend/utils/misc/postgresql.conf.sample
***************
*** 220,227 ****
  #constraint_exclusion = partition	# on, off, or partition
  #cursor_tuple_fraction = 0.1		# range 0.0-1.0
  #from_collapse_limit = 8
! #join_collapse_limit = 8		# 1 disables collapsing of explicit 
! 					# JOIN clauses
  
  
  #------------------------------------------------------------------------------
--- 220,229 ----
  #constraint_exclusion = partition	# on, off, or partition
  #cursor_tuple_fraction = 0.1		# range 0.0-1.0
  #from_collapse_limit = 8
! #join_collapse_limit = 0		# 1 disables collapsing of explicit 
! 					# JOIN clauses, 0 always allows collapsing,
! 					# >1 allows collapsing of lists when FROM clause will
! 					# have <= join_collapse_limit items
  
  
  #------------------------------------------------------------------------------
