Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72933a9

Browse files
committed
Back off previous patch to skip projection step in scan plan nodes,
in the case where the node immediately above the scan is a Hash, Sort,or Material node. In these cases it's better to do the projectionso that we don't store unneeded columns in the hash/sort/materializetable. Per discussion a few days ago with Anagh Lal.
1 parent51972a9 commit72933a9

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

‎src/backend/optimizer/plan/createplan.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.136 2003/02/09 06:56:27 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.137 2003/02/16 06:06:32 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -35,6 +35,7 @@
3535

3636
staticScan*create_scan_plan(Query*root,Path*best_path);
3737
staticbooluse_physical_tlist(RelOptInfo*rel);
38+
staticvoiddisuse_physical_tlist(Plan*plan,Path*path);
3839
staticJoin*create_join_plan(Query*root,JoinPath*best_path);
3940
staticAppend*create_append_plan(Query*root,AppendPath*best_path);
4041
staticResult*create_result_plan(Query*root,ResultPath*best_path);
@@ -310,6 +311,33 @@ use_physical_tlist(RelOptInfo *rel)
310311
return true;
311312
}
312313

314+
/*
315+
* disuse_physical_tlist
316+
*Switch a plan node back to emitting only Vars actually referenced.
317+
*
318+
* If the plan node immediately above a scan would prefer to get only
319+
* needed Vars and not a physical tlist, it must call this routine to
320+
* undo the decision made by use_physical_tlist(). Currently, Hash, Sort,
321+
* and Material nodes want this, so they don't have to store useless columns.
322+
*/
323+
staticvoid
324+
disuse_physical_tlist(Plan*plan,Path*path)
325+
{
326+
/* Only need to undo it for path types handled by create_scan_plan() */
327+
switch (path->pathtype)
328+
{
329+
caseT_IndexScan:
330+
caseT_SeqScan:
331+
caseT_TidScan:
332+
caseT_SubqueryScan:
333+
caseT_FunctionScan:
334+
plan->targetlist=path->parent->targetlist;
335+
break;
336+
default:
337+
break;
338+
}
339+
}
340+
313341
/*
314342
* create_join_plan
315343
* Create a join plan for 'best_path' and (recursively) plans for its
@@ -468,6 +496,9 @@ create_material_plan(Query *root, MaterialPath *best_path)
468496

469497
subplan=create_plan(root,best_path->subpath);
470498

499+
/* We don't want any excess columns in the materialized tuples */
500+
disuse_physical_tlist(subplan,best_path->subpath);
501+
471502
plan=make_material(subplan->targetlist,subplan);
472503

473504
copy_path_costsize(&plan->plan, (Path*)best_path);
@@ -906,20 +937,27 @@ create_mergejoin_plan(Query *root,
906937
/*
907938
* Create explicit sort nodes for the outer and inner join paths if
908939
* necessary. The sort cost was already accounted for in the path.
940+
* Make sure there are no excess columns in the inputs if sorting.
909941
*/
910942
if (best_path->outersortkeys)
943+
{
944+
disuse_physical_tlist(outer_plan,best_path->jpath.outerjoinpath);
911945
outer_plan= (Plan*)
912946
make_sort_from_pathkeys(root,
913947
outer_plan,
914948
best_path->jpath.outerjoinpath->parent->relids,
915949
best_path->outersortkeys);
950+
}
916951

917952
if (best_path->innersortkeys)
953+
{
954+
disuse_physical_tlist(inner_plan,best_path->jpath.innerjoinpath);
918955
inner_plan= (Plan*)
919956
make_sort_from_pathkeys(root,
920957
inner_plan,
921958
best_path->jpath.innerjoinpath->parent->relids,
922959
best_path->innersortkeys);
960+
}
923961

924962
/*
925963
* Now we can build the mergejoin node.
@@ -976,6 +1014,9 @@ create_hashjoin_plan(Query *root,
9761014
innerhashkeys=lappend(innerhashkeys,get_rightop(lfirst(hcl)));
9771015
}
9781016

1017+
/* We don't want any excess columns in the hashed tuples */
1018+
disuse_physical_tlist(inner_plan,best_path->jpath.innerjoinpath);
1019+
9791020
/*
9801021
* Build the hash node and hash join node.
9811022
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp