⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pathnode.c

📁 关系型数据库 Postgresql 6.5.2
💻 C
📖 第 1 页 / 共 2 页
字号:
				  RelOptInfo *rel,				  RelOptInfo *index,				  List *restriction_clauses,				  bool is_join_scan){	IndexPath  *pathnode = makeNode(IndexPath);	pathnode->path.pathtype = T_IndexScan;	pathnode->path.parent = rel;	pathnode->path.pathorder = makeNode(PathOrder);	pathnode->path.pathorder->ordtype = SORTOP_ORDER;	pathnode->path.pathorder->ord.sortop = index->ordering;	pathnode->indexid = index->relids;	pathnode->indexkeys = index->indexkeys;	pathnode->indexqual = NIL;	/*	 * copy restrictinfo list into path for expensive function processing	 * JMH, 7/7/92	 */	pathnode->path.loc_restrictinfo = set_difference((List *) copyObject((Node *) rel->restrictinfo),										   (List *) restriction_clauses);	/*	 * The index must have an ordering for the path to have (ordering)	 * keys, and vice versa.	 */	if (pathnode->path.pathorder->ord.sortop)	{		pathnode->path.pathkeys = collect_index_pathkeys(index->indexkeys,														 rel->targetlist);		/*		 * Check that the keys haven't 'disappeared', since they may no		 * longer be in the target list (i.e., index keys that are not		 * relevant to the scan are not applied to the scan path node, so		 * if no index keys were found, we can't order the path).		 */		if (pathnode->path.pathkeys == NULL)			pathnode->path.pathorder->ord.sortop = NULL;	}	else		pathnode->path.pathkeys = NULL;	if (is_join_scan || restriction_clauses == NULL)	{		/*		 * Indices used for joins or sorting result nodes don't restrict		 * the result at all, they simply order it, so compute the scan		 * cost accordingly -- use a selectivity of 1.0.		 *//* is the statement above really true?	what about IndexScan as the   inner of a join? */		pathnode->path.path_cost = cost_index(lfirsti(index->relids),											  index->pages,											  1.0,											  rel->pages,											  rel->tuples,											  index->pages,											  index->tuples,											  false);#ifdef NOT_USED		/* add in expensive functions cost!  -- JMH, 7/7/92 */		if (XfuncMode != XFUNC_OFF)		{			pathnode->path_cost = (pathnode->path_cost +								 xfunc_get_path_cost((Path *) pathnode));		}#endif	}	else	{		/*		 * Compute scan cost for the case when 'index' is used with a		 * restriction clause.		 */		List	   *attnos;		List	   *values;		List	   *flags;		float		npages;		float		selec;		Cost		clausesel;		get_relattvals(restriction_clauses,					   &attnos,					   &values,					   &flags);		index_selectivity(lfirsti(index->relids),						  index->classlist,						  get_opnos(restriction_clauses),						  getrelid(lfirsti(rel->relids),								   root->rtable),						  attnos,						  values,						  flags,						  length(restriction_clauses),						  &npages,						  &selec);		/* each clause gets an equal selectivity */		clausesel = pow(selec, 1.0 / (double) length(restriction_clauses));		pathnode->indexqual = restriction_clauses;		pathnode->path.path_cost = cost_index(lfirsti(index->relids),											  (int) npages,											  selec,											  rel->pages,											  rel->tuples,											  index->pages,											  index->tuples,											  false);#ifdef NOT_USED		/* add in expensive functions cost!  -- JMH, 7/7/92 */		if (XfuncMode != XFUNC_OFF)			pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode);#endif		/*		 * Set selectivities of clauses used with index to the selectivity		 * of this index, subdividing the selectivity equally over each of		 * the clauses.		 */		/* XXX Can this divide the selectivities in a better way? */		set_clause_selectivities(restriction_clauses, clausesel);	}	return pathnode;}/* * create_nestloop_path *	  Creates a pathnode corresponding to a nestloop join between two *	  relations. * * 'joinrel' is the join relation. * 'outer_rel' is the outer join relation * 'outer_path' is the outer join path. * 'inner_path' is the inner join path. * 'pathkeys' are the keys of the path * * Returns the resulting path node. * */NestPath   *create_nestloop_path(RelOptInfo *joinrel,					 RelOptInfo *outer_rel,					 Path *outer_path,					 Path *inner_path,					 List *pathkeys){	NestPath   *pathnode = makeNode(NestPath);	pathnode->path.pathtype = T_NestLoop;	pathnode->path.parent = joinrel;	pathnode->outerjoinpath = outer_path;	pathnode->innerjoinpath = inner_path;	pathnode->pathinfo = joinrel->restrictinfo;	pathnode->path.pathkeys = pathkeys;	pathnode->path.joinid = NIL;	pathnode->path.outerjoincost = (Cost) 0.0;	pathnode->path.loc_restrictinfo = NIL;	pathnode->path.pathorder = makeNode(PathOrder);	if (pathkeys)	{		pathnode->path.pathorder->ordtype = outer_path->pathorder->ordtype;		if (outer_path->pathorder->ordtype == SORTOP_ORDER)			pathnode->path.pathorder->ord.sortop = outer_path->pathorder->ord.sortop;		else			pathnode->path.pathorder->ord.merge = outer_path->pathorder->ord.merge;	}	else	{		pathnode->path.pathorder->ordtype = SORTOP_ORDER;		pathnode->path.pathorder->ord.sortop = NULL;	}	pathnode->path.path_cost = cost_nestloop(outer_path->path_cost,											 inner_path->path_cost,											 outer_rel->size,											 inner_path->parent->size,											 page_size(outer_rel->size,													   outer_rel->width),											 IsA(inner_path, IndexPath));	/* add in expensive function costs -- JMH 7/7/92 */#ifdef NOT_USED	if (XfuncMode != XFUNC_OFF)		pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode);#endif	return pathnode;}/* * create_mergejoin_path *	  Creates a pathnode corresponding to a mergejoin join between *	  two relations * * 'joinrel' is the join relation * 'outersize' is the number of tuples in the outer relation * 'innersize' is the number of tuples in the inner relation * 'outerwidth' is the number of bytes per tuple in the outer relation * 'innerwidth' is the number of bytes per tuple in the inner relation * 'outer_path' is the outer path * 'inner_path' is the inner path * 'pathkeys' are the new keys of the join relation * 'order' is the sort order required for the merge * 'mergeclauses' are the applicable join/restriction clauses * 'outersortkeys' are the sort varkeys for the outer relation * 'innersortkeys' are the sort varkeys for the inner relation * */MergePath  *create_mergejoin_path(RelOptInfo *joinrel,					  int outersize,					  int innersize,					  int outerwidth,					  int innerwidth,					  Path *outer_path,					  Path *inner_path,					  List *pathkeys,					  MergeOrder *order,					  List *mergeclauses,					  List *outersortkeys,					  List *innersortkeys){	MergePath  *pathnode = makeNode(MergePath);	pathnode->jpath.path.pathtype = T_MergeJoin;	pathnode->jpath.path.parent = joinrel;	pathnode->jpath.outerjoinpath = outer_path;	pathnode->jpath.innerjoinpath = inner_path;	pathnode->jpath.pathinfo = joinrel->restrictinfo;	pathnode->jpath.path.pathkeys = pathkeys;	pathnode->jpath.path.pathorder = makeNode(PathOrder);	pathnode->jpath.path.pathorder->ordtype = MERGE_ORDER;	pathnode->jpath.path.pathorder->ord.merge = order;	pathnode->path_mergeclauses = mergeclauses;	pathnode->jpath.path.loc_restrictinfo = NIL;	pathnode->outersortkeys = outersortkeys;	pathnode->innersortkeys = innersortkeys;	pathnode->jpath.path.path_cost = cost_mergejoin(outer_path->path_cost,													inner_path->path_cost,													outersortkeys,													innersortkeys,													outersize,													innersize,													outerwidth,													innerwidth);	/* add in expensive function costs -- JMH 7/7/92 */#ifdef NOT_USED	if (XfuncMode != XFUNC_OFF)		pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode);#endif	return pathnode;}/* * create_hashjoin_path--						XXX HASH *	  Creates a pathnode corresponding to a hash join between two relations. * * 'joinrel' is the join relation * 'outersize' is the number of tuples in the outer relation * 'innersize' is the number of tuples in the inner relation * 'outerwidth' is the number of bytes per tuple in the outer relation * 'innerwidth' is the number of bytes per tuple in the inner relation * 'outer_path' is the outer path * 'inner_path' is the inner path * 'pathkeys' are the new keys of the join relation * 'operator' is the hashjoin operator * 'hashclauses' are the applicable join/restriction clauses * 'outerkeys' are the sort varkeys for the outer relation * 'innerkeys' are the sort varkeys for the inner relation * */HashPath   *create_hashjoin_path(RelOptInfo *joinrel,					 int outersize,					 int innersize,					 int outerwidth,					 int innerwidth,					 Path *outer_path,					 Path *inner_path,					 List *pathkeys,					 Oid operator,					 List *hashclauses,					 List *outerkeys,					 List *innerkeys){	HashPath   *pathnode = makeNode(HashPath);	pathnode->jpath.path.pathtype = T_HashJoin;	pathnode->jpath.path.parent = joinrel;	pathnode->jpath.outerjoinpath = outer_path;	pathnode->jpath.innerjoinpath = inner_path;	pathnode->jpath.pathinfo = joinrel->restrictinfo;	pathnode->jpath.path.loc_restrictinfo = NIL;	pathnode->jpath.path.pathkeys = pathkeys;	pathnode->jpath.path.pathorder = makeNode(PathOrder);	pathnode->jpath.path.pathorder->ordtype = SORTOP_ORDER;	pathnode->jpath.path.pathorder->ord.sortop = NULL;	pathnode->jpath.path.outerjoincost = (Cost) 0.0;	pathnode->jpath.path.joinid = (Relids) NULL;	/* pathnode->hashjoinoperator = operator;  */	pathnode->path_hashclauses = hashclauses;	pathnode->outerhashkeys = outerkeys;	pathnode->innerhashkeys = innerkeys;	pathnode->jpath.path.path_cost = cost_hashjoin(outer_path->path_cost,												   inner_path->path_cost,												   outerkeys,												   innerkeys,												   outersize, innersize,												 outerwidth, innerwidth);	/* add in expensive function costs -- JMH 7/7/92 */#ifdef NOT_USED	if (XfuncMode != XFUNC_OFF)		pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode);#endif	return pathnode;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -