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

Commit2a64931

Browse files
committed
Salvage a little bit of work from a failed patch: simplify and speed up
set_rel_width(). The code had been catering for the possibility of differentvarnos in the relation targetlist, but this is impossible for a base relation(and if it were possible, putting all the widths in the same RelOptInfo wouldbe wrong anyway).
1 parentab16485 commit2a64931

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

‎src/backend/optimizer/path/costsize.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* Portions Copyright (c) 1994, Regents of the University of California
5555
*
5656
* IDENTIFICATION
57-
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.198 2008/10/04 21:56:53 tgl Exp $
57+
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.199 2008/10/17 20:27:24 tgl Exp $
5858
*
5959
*-------------------------------------------------------------------------
6060
*/
@@ -2608,24 +2608,14 @@ set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel, Plan *cteplan)
26082608
staticvoid
26092609
set_rel_width(PlannerInfo*root,RelOptInfo*rel)
26102610
{
2611+
Oidreloid=planner_rt_fetch(rel->relid,root)->relid;
26112612
int32tuple_width=0;
26122613
ListCell*tllist;
2613-
Oidrel_reloid;
2614-
2615-
/*
2616-
* Usually (perhaps always), all the Vars have the same reloid, so we can
2617-
* save some redundant list-searching by doing getrelid just once.
2618-
*/
2619-
if (rel->relid>0)
2620-
rel_reloid=getrelid(rel->relid,root->parse->rtable);
2621-
else
2622-
rel_reloid=InvalidOid;/* probably can't happen */
26232614

26242615
foreach(tllist,rel->reltargetlist)
26252616
{
26262617
Var*var= (Var*)lfirst(tllist);
26272618
intndx;
2628-
Oidvar_reloid;
26292619
int32item_width;
26302620

26312621
/* For now, punt on whole-row child Vars */
@@ -2635,6 +2625,10 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
26352625
continue;
26362626
}
26372627

2628+
Assert(var->varno==rel->relid);
2629+
Assert(var->varattno >=rel->min_attr);
2630+
Assert(var->varattno <=rel->max_attr);
2631+
26382632
ndx=var->varattno-rel->min_attr;
26392633

26402634
/*
@@ -2646,14 +2640,9 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
26462640
continue;
26472641
}
26482642

2649-
if (var->varno==rel->relid)
2650-
var_reloid=rel_reloid;
2651-
else
2652-
var_reloid=getrelid(var->varno,root->parse->rtable);
2653-
2654-
if (var_reloid!=InvalidOid)
2643+
if (reloid!=InvalidOid)
26552644
{
2656-
item_width=get_attavgwidth(var_reloid,var->varattno);
2645+
item_width=get_attavgwidth(reloid,var->varattno);
26572646
if (item_width>0)
26582647
{
26592648
rel->attr_widths[ndx]=item_width;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp