mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	Replace has_multiple_baserels() with a bitmap test on all_baserels.
Since we added the PlannerInfo.all_baserels set, it's not really necessary to grovel over the rangetable to count baserels in the current query. So let's drop has_multiple_baserels() in favor of a bms_membership() test. This might be microscopically faster, but the main point is to remove some unnecessary code. Richard Guo Discussion: https://postgr.es/m/CAMbWs4_8RcSbbfs1ASZLrMuL0c0EQgXWcoLTQD8swBRY_pQQiA@mail.gmail.com
This commit is contained in:
		| @@ -2190,28 +2190,6 @@ set_dummy_rel_pathlist(RelOptInfo *rel) | |||||||
| 	set_cheapest(rel); | 	set_cheapest(rel); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* quick-and-dirty test to see if any joining is needed */ |  | ||||||
| static bool |  | ||||||
| has_multiple_baserels(PlannerInfo *root) |  | ||||||
| { |  | ||||||
| 	int			num_base_rels = 0; |  | ||||||
| 	Index		rti; |  | ||||||
|  |  | ||||||
| 	for (rti = 1; rti < root->simple_rel_array_size; rti++) |  | ||||||
| 	{ |  | ||||||
| 		RelOptInfo *brel = root->simple_rel_array[rti]; |  | ||||||
|  |  | ||||||
| 		if (brel == NULL) |  | ||||||
| 			continue; |  | ||||||
|  |  | ||||||
| 		/* ignore RTEs that are "other rels" */ |  | ||||||
| 		if (brel->reloptkind == RELOPT_BASEREL) |  | ||||||
| 			if (++num_base_rels > 1) |  | ||||||
| 				return true; |  | ||||||
| 	} |  | ||||||
| 	return false; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * find_window_run_conditions |  * find_window_run_conditions | ||||||
|  *		Determine if 'wfunc' is really a WindowFunc and call its prosupport |  *		Determine if 'wfunc' is really a WindowFunc and call its prosupport | ||||||
| @@ -2661,7 +2639,7 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, | |||||||
| 		root->hasHavingQual || | 		root->hasHavingQual || | ||||||
| 		parse->distinctClause || | 		parse->distinctClause || | ||||||
| 		parse->sortClause || | 		parse->sortClause || | ||||||
| 		has_multiple_baserels(root)) | 		bms_membership(root->all_baserels) == BMS_MULTIPLE) | ||||||
| 		tuple_fraction = 0.0;	/* default case */ | 		tuple_fraction = 0.0;	/* default case */ | ||||||
| 	else | 	else | ||||||
| 		tuple_fraction = root->tuple_fraction; | 		tuple_fraction = root->tuple_fraction; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user