Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
3cbcb78a
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3cbcb78a
编写于
2月 18, 2000
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Plug some more memory leaks in the planner. It still leaks like a sieve,
but this is as good as it'll get for this release...
上级
bc8a39be
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
49 deletion
+89
-49
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinpath.c
+39
-20
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/path/pathkeys.c
+15
-3
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/createplan.c
+8
-7
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/pathnode.c
+4
-2
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/relnode.c
+2
-5
src/include/nodes/relation.h
src/include/nodes/relation.h
+21
-12
未找到文件。
src/backend/optimizer/path/joinpath.c
浏览文件 @
3cbcb78a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.5
2 2000/02/15 20:49:17
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.5
3 2000/02/18 23:47:19
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -171,9 +171,13 @@ sort_inner_and_outer(Query *root,
List
*
merge_pathkeys
;
/* Make a mergeclause list with this guy first. */
curclause_list
=
lcons
(
restrictinfo
,
lremove
(
restrictinfo
,
listCopy
(
mergeclause_list
)));
if
(
i
!=
mergeclause_list
)
curclause_list
=
lcons
(
restrictinfo
,
lremove
(
restrictinfo
,
listCopy
(
mergeclause_list
)));
else
curclause_list
=
mergeclause_list
;
/* no work at first one... */
/* Build sort pathkeys for both sides.
*
* Note: it's possible that the cheapest paths will already be
...
...
@@ -203,7 +207,7 @@ sort_inner_and_outer(Query *root,
innerrel
->
cheapest_total_path
,
restrictlist
,
merge_pathkeys
,
get_actual_clauses
(
curclause_list
)
,
curclause_list
,
outerkeys
,
innerkeys
));
}
...
...
@@ -265,6 +269,7 @@ match_unsorted_outer(Query *root,
List
*
trialsortkeys
;
Path
*
cheapest_startup_inner
;
Path
*
cheapest_total_inner
;
int
num_mergeclauses
;
int
clausecnt
;
/*
...
...
@@ -325,7 +330,7 @@ match_unsorted_outer(Query *root,
innerrel
->
cheapest_total_path
,
restrictlist
,
merge_pathkeys
,
get_actual_clauses
(
mergeclauses
)
,
mergeclauses
,
NIL
,
innersortkeys
));
...
...
@@ -337,10 +342,12 @@ match_unsorted_outer(Query *root,
trialsortkeys
=
listCopy
(
innersortkeys
);
/* modifiable copy */
cheapest_startup_inner
=
NULL
;
cheapest_total_inner
=
NULL
;
num_mergeclauses
=
length
(
mergeclauses
);
for
(
clausecnt
=
length
(
mergeclauses
)
;
clausecnt
>
0
;
clausecnt
--
)
for
(
clausecnt
=
num_mergeclauses
;
clausecnt
>
0
;
clausecnt
--
)
{
Path
*
innerpath
;
List
*
newclauses
=
NIL
;
/* Look for an inner path ordered well enough to merge with
* the first 'clausecnt' mergeclauses. NB: trialsortkeys list
...
...
@@ -356,10 +363,11 @@ match_unsorted_outer(Query *root,
TOTAL_COST
)
<
0
))
{
/* Found a cheap (or even-cheaper) sorted path */
List
*
newclauses
;
newclauses
=
ltruncate
(
clausecnt
,
get_actual_clauses
(
mergeclauses
));
if
(
clausecnt
<
num_mergeclauses
)
newclauses
=
ltruncate
(
clausecnt
,
listCopy
(
mergeclauses
));
else
newclauses
=
mergeclauses
;
add_path
(
joinrel
,
(
Path
*
)
create_mergejoin_path
(
joinrel
,
outerpath
,
...
...
@@ -383,10 +391,17 @@ match_unsorted_outer(Query *root,
/* Found a cheap (or even-cheaper) sorted path */
if
(
innerpath
!=
cheapest_total_inner
)
{
List
*
newclauses
;
newclauses
=
ltruncate
(
clausecnt
,
get_actual_clauses
(
mergeclauses
));
/* Avoid rebuilding clause list if we already made one;
* saves memory in big join trees...
*/
if
(
newclauses
==
NIL
)
{
if
(
clausecnt
<
num_mergeclauses
)
newclauses
=
ltruncate
(
clausecnt
,
listCopy
(
mergeclauses
));
else
newclauses
=
mergeclauses
;
}
add_path
(
joinrel
,
(
Path
*
)
create_mergejoin_path
(
joinrel
,
outerpath
,
...
...
@@ -461,7 +476,7 @@ match_unsorted_inner(Query *root,
innerpath
,
restrictlist
,
merge_pathkeys
,
get_actual_clauses
(
mergeclauses
)
,
mergeclauses
,
outersortkeys
,
NIL
));
/*
...
...
@@ -487,7 +502,7 @@ match_unsorted_inner(Query *root,
innerpath
,
restrictlist
,
merge_pathkeys
,
get_actual_clauses
(
mergeclauses
)
,
mergeclauses
,
NIL
,
NIL
));
...
...
@@ -505,7 +520,7 @@ match_unsorted_inner(Query *root,
innerpath
,
restrictlist
,
merge_pathkeys
,
get_actual_clauses
(
mergeclauses
)
,
mergeclauses
,
NIL
,
NIL
));
}
...
...
@@ -552,6 +567,7 @@ hash_inner_and_outer(Query *root,
Var
*
left
,
*
right
,
*
inner
;
List
*
hashclauses
;
Selectivity
innerdisbursion
;
if
(
restrictinfo
->
hashjoinoperator
==
InvalidOid
)
...
...
@@ -572,6 +588,9 @@ hash_inner_and_outer(Query *root,
else
continue
;
/* no good for these input relations */
/* always a one-element list of hash clauses */
hashclauses
=
lcons
(
restrictinfo
,
NIL
);
/* estimate disbursion of inner var for costing purposes */
innerdisbursion
=
estimate_disbursion
(
root
,
inner
);
...
...
@@ -585,7 +604,7 @@ hash_inner_and_outer(Query *root,
outerrel
->
cheapest_total_path
,
innerrel
->
cheapest_total_path
,
restrictlist
,
lcons
(
clause
,
NIL
)
,
hashclauses
,
innerdisbursion
));
if
(
outerrel
->
cheapest_startup_path
!=
outerrel
->
cheapest_total_path
)
add_path
(
joinrel
,
(
Path
*
)
...
...
@@ -593,7 +612,7 @@ hash_inner_and_outer(Query *root,
outerrel
->
cheapest_startup_path
,
innerrel
->
cheapest_total_path
,
restrictlist
,
lcons
(
clause
,
NIL
)
,
hashclauses
,
innerdisbursion
));
}
}
...
...
src/backend/optimizer/path/pathkeys.c
浏览文件 @
3cbcb78a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.
19 2000/02/15 20:49:17
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.
20 2000/02/18 23:47:19
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -778,6 +778,7 @@ make_pathkeys_for_mergeclauses(Query *root,
Node
*
key
;
Oid
sortop
;
PathKeyItem
*
item
;
List
*
pathkey
;
Assert
(
restrictinfo
->
mergejoinoperator
!=
InvalidOid
);
...
...
@@ -791,10 +792,21 @@ make_pathkeys_for_mergeclauses(Query *root,
key
=
(
Node
*
)
get_leftop
(
restrictinfo
->
clause
);
sortop
=
restrictinfo
->
left_sortop
;
/*
* Add a pathkey sublist for this sort item
* Find pathkey sublist for this sort item. We expect to find
* the canonical set including the mergeclause's left and right
* sides; if we get back just the one item, something is rotten.
*/
item
=
makePathKeyItem
(
key
,
sortop
);
pathkeys
=
lappend
(
pathkeys
,
make_canonical_pathkey
(
root
,
item
));
pathkey
=
make_canonical_pathkey
(
root
,
item
);
Assert
(
length
(
pathkey
)
>
1
);
/*
* Since the item we just made is not in the returned canonical set,
* we can free it --- this saves a useful amount of storage in a
* big join tree.
*/
pfree
(
item
);
pathkeys
=
lappend
(
pathkeys
,
pathkey
);
}
return
pathkeys
;
...
...
src/backend/optimizer/plan/createplan.c
浏览文件 @
3cbcb78a
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.8
5 2000/02/15 20:49:18
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.8
6 2000/02/18 23:47:21
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -626,13 +626,14 @@ create_mergejoin_node(MergePath *best_path,
*
mergeclauses
;
MergeJoin
*
join_node
;
mergeclauses
=
get_actual_clauses
(
best_path
->
path_mergeclauses
);
/*
* Remove the mergeclauses from the list of join qual clauses,
* leaving the list of quals that must be checked as qpquals.
* Set those clauses to contain INNER/OUTER var references.
*/
qpqual
=
join_references
(
set_difference
(
clauses
,
best_path
->
path_mergeclauses
),
qpqual
=
join_references
(
set_difference
(
clauses
,
mergeclauses
),
outer_tlist
,
inner_tlist
,
(
Index
)
0
);
...
...
@@ -641,7 +642,7 @@ create_mergejoin_node(MergePath *best_path,
* Now set the references in the mergeclauses and rearrange them so
* that the outer variable is always on the left.
*/
mergeclauses
=
switch_outer
(
join_references
(
best_path
->
path_
mergeclauses
,
mergeclauses
=
switch_outer
(
join_references
(
mergeclauses
,
outer_tlist
,
inner_tlist
,
(
Index
)
0
));
...
...
@@ -692,14 +693,14 @@ create_hashjoin_node(HashPath *best_path,
* We represent it as a list anyway, for convenience with routines
* that want to work on lists of clauses.
*/
hashclauses
=
get_actual_clauses
(
best_path
->
path_hashclauses
);
/*
* Remove the hashclauses from the list of join qual clauses,
* leaving the list of quals that must be checked as qpquals.
* Set those clauses to contain INNER/OUTER var references.
*/
qpqual
=
join_references
(
set_difference
(
clauses
,
best_path
->
path_hashclauses
),
qpqual
=
join_references
(
set_difference
(
clauses
,
hashclauses
),
outer_tlist
,
inner_tlist
,
(
Index
)
0
);
...
...
@@ -708,7 +709,7 @@ create_hashjoin_node(HashPath *best_path,
* Now set the references in the hashclauses and rearrange them so
* that the outer variable is always on the left.
*/
hashclauses
=
switch_outer
(
join_references
(
best_path
->
path_
hashclauses
,
hashclauses
=
switch_outer
(
join_references
(
hashclauses
,
outer_tlist
,
inner_tlist
,
(
Index
)
0
));
...
...
src/backend/optimizer/util/pathnode.c
浏览文件 @
3cbcb78a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.6
0 2000/02/15 20:49:2
0 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.6
1 2000/02/18 23:47:3
0 tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -416,7 +416,8 @@ create_nestloop_path(RelOptInfo *joinrel,
* 'inner_path' is the inner path
* 'restrict_clauses' are the RestrictInfo nodes to apply at the join
* 'pathkeys' are the path keys of the new join path
* 'mergeclauses' are the applicable join/restriction clauses
* 'mergeclauses' are the RestrictInfo nodes to use as merge clauses
* (this should be a subset of the restrict_clauses list)
* 'outersortkeys' are the sort varkeys for the outer relation
* 'innersortkeys' are the sort varkeys for the inner relation
*
...
...
@@ -473,6 +474,7 @@ create_mergejoin_path(RelOptInfo *joinrel,
* 'inner_path' is the cheapest inner path
* 'restrict_clauses' are the RestrictInfo nodes to apply at the join
* 'hashclauses' is a list of the hash join clause (always a 1-element list)
* (this should be a subset of the restrict_clauses list)
* 'innerdisbursion' is an estimate of the disbursion of the inner hash key
*
*/
...
...
src/backend/optimizer/util/relnode.c
浏览文件 @
3cbcb78a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.2
4 2000/02/15 20:49:2
1 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.2
5 2000/02/18 23:47:3
1 tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -345,11 +345,8 @@ subbuild_joinrel_restrictlist(RelOptInfo *joinrel,
foreach
(
xjoininfo
,
joininfo_list
)
{
JoinInfo
*
joininfo
=
(
JoinInfo
*
)
lfirst
(
xjoininfo
);
Relids
new_unjoined_relids
;
new_unjoined_relids
=
set_differencei
(
joininfo
->
unjoined_relids
,
joinrel
->
relids
);
if
(
new_unjoined_relids
==
NIL
)
if
(
is_subseti
(
joininfo
->
unjoined_relids
,
joinrel
->
relids
))
{
/*
* Clauses in this JoinInfo list become restriction clauses
...
...
src/include/nodes/relation.h
浏览文件 @
3cbcb78a
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: relation.h,v 1.4
4 2000/02/15 20:49:25
tgl Exp $
* $Id: relation.h,v 1.4
5 2000/02/18 23:47:17
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -237,6 +237,8 @@ typedef struct Path
* are usable as indexquals (as determined by indxpath.c) may appear here.
* NOTE that the semantics of the top-level list in 'indexqual' is OR
* combination, while the sublists are implicitly AND combinations!
* Also note that indexquals lists do not contain RestrictInfo nodes,
* just bare clause expressions.
*
* 'indexscandir' is one of:
* ForwardScanDirection: forward scan of an ordered index
...
...
@@ -293,32 +295,39 @@ typedef JoinPath NestPath;
/*
* A mergejoin path has these fields.
*
* path_mergeclauses lists the clauses (in the form of RestrictInfos)
* that will be used in the merge. (Before 7.0, this was a list of
* bare clause expressions, but we can save on list memory by leaving
* it in the form of a RestrictInfo list.)
*
* Note that the mergeclauses are a subset of the parent relation's
* restriction-clause list. Any join clauses that are not mergejoinable
* appear only in the parent's restrict list, and must be checked by a
* qpqual at execution time.
*
* outersortkeys (resp. innersortkeys) is NIL if the outer path
* (resp. inner path) is already ordered appropriately for the
* mergejoin. If it is not NIL then it is a PathKeys list describing
* the ordering that must be created by an explicit sort step.
*/
typedef
struct
MergePath
{
JoinPath
jpath
;
List
*
path_mergeclauses
;
/* join clauses used for merge */
/*
* outersortkeys (resp. innersortkeys) is NIL if the outer path
* (resp. inner path) is already ordered appropriately for the
* mergejoin. If it is not NIL then it is a PathKeys list describing
* the ordering that must be created by an explicit sort step.
*/
List
*
outersortkeys
;
List
*
innersortkeys
;
List
*
path_mergeclauses
;
/* join clauses to be used for merge */
List
*
outersortkeys
;
/* keys for explicit sort, if any */
List
*
innersortkeys
;
/* keys for explicit sort, if any */
}
MergePath
;
/*
* A hashjoin path has these fields.
*
* The remarks above for mergeclauses apply for hashclauses as well.
* However, hashjoin does not care what order its inputs appear in,
* so we have no need for sortkeys.
* (But note that path_hashclauses will always be a one-element list,
* since we only hash on one hashable clause.)
*
* Hashjoin does not care what order its inputs appear in, so we have
* no need for sortkeys.
*/
typedef
struct
HashPath
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录