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

Commit7c7139c

Browse files
committed
Knock down a couple more lappend() hotspots for large WHERE clauses.
1 parent8a6ac83 commit7c7139c

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

‎src/backend/commands/explain.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.109 2003/05/08 18:16:36 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.110 2003/05/28 23:06:16 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1033,12 +1033,15 @@ make_ors_ands_explicit(List *orclauses)
10331033
return (Node*)make_ands_explicit(lfirst(orclauses));
10341034
else
10351035
{
1036-
List*args=NIL;
1036+
FastListargs;
10371037
List*orptr;
10381038

1039+
FastListInit(&args);
10391040
foreach(orptr,orclauses)
1040-
args=lappend(args,make_ands_explicit(lfirst(orptr)));
1041+
{
1042+
FastAppend(&args,make_ands_explicit(lfirst(orptr)));
1043+
}
10411044

1042-
return (Node*)make_orclause(args);
1045+
return (Node*)make_orclause(FastListValue(&args));
10431046
}
10441047
}

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

Lines changed: 33 additions & 28 deletions
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.143 2003/05/2816:03:56 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.144 2003/05/2823:06:16 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -681,7 +681,7 @@ create_indexscan_plan(Query *root,
681681
Expr*indxqual_or_expr=NULL;
682682
List*fixed_indxqual;
683683
List*recheck_indxqual;
684-
List*indexids;
684+
FastListindexids;
685685
List*ixinfo;
686686
IndexScan*scan_plan;
687687

@@ -692,12 +692,12 @@ create_indexscan_plan(Query *root,
692692
/*
693693
* Build list of index OIDs.
694694
*/
695-
indexids=NIL;
695+
FastListInit(&indexids);
696696
foreach(ixinfo,best_path->indexinfo)
697697
{
698698
IndexOptInfo*index= (IndexOptInfo*)lfirst(ixinfo);
699699

700-
indexids=lappendo(indexids,index->indexoid);
700+
FastAppendo(&indexids,index->indexoid);
701701
}
702702

703703
/*
@@ -719,15 +719,15 @@ create_indexscan_plan(Query *root,
719719
* the implicit OR and AND semantics of the first- and
720720
* second-level lists.
721721
*/
722-
List*orclauses=NIL;
722+
FastListorclauses;
723723
List*orclause;
724724

725+
FastListInit(&orclauses);
725726
foreach(orclause,indxqual)
726727
{
727-
orclauses=lappend(orclauses,
728-
make_ands_explicit(lfirst(orclause)));
728+
FastAppend(&orclauses,make_ands_explicit(lfirst(orclause)));
729729
}
730-
indxqual_or_expr=make_orclause(orclauses);
730+
indxqual_or_expr=make_orclause(FastListValue(&orclauses));
731731

732732
qpqual=set_difference(scan_clauses,makeList1(indxqual_or_expr));
733733
}
@@ -778,7 +778,7 @@ create_indexscan_plan(Query *root,
778778
scan_plan=make_indexscan(tlist,
779779
qpqual,
780780
baserelid,
781-
indexids,
781+
FastListValue(&indexids),
782782
fixed_indxqual,
783783
indxqual,
784784
best_path->indexscandir);
@@ -1091,13 +1091,15 @@ static void
10911091
fix_indxqual_references(List*indexquals,IndexPath*index_path,
10921092
List**fixed_indexquals,List**recheck_indexquals)
10931093
{
1094-
List*fixed_quals=NIL;
1095-
List*recheck_quals=NIL;
1094+
FastListfixed_quals;
1095+
FastListrecheck_quals;
10961096
Relidsbaserelids=index_path->path.parent->relids;
10971097
intbaserelid=index_path->path.parent->relid;
10981098
List*ixinfo=index_path->indexinfo;
10991099
List*i;
11001100

1101+
FastListInit(&fixed_quals);
1102+
FastListInit(&recheck_quals);
11011103
foreach(i,indexquals)
11021104
{
11031105
List*indexqual=lfirst(i);
@@ -1107,15 +1109,15 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path,
11071109

11081110
fix_indxqual_sublist(indexqual,baserelids,baserelid,index,
11091111
&fixed_qual,&recheck_qual);
1110-
fixed_quals=lappend(fixed_quals,fixed_qual);
1112+
FastAppend(&fixed_quals,fixed_qual);
11111113
if (recheck_qual!=NIL)
1112-
recheck_quals=lappend(recheck_quals,recheck_qual);
1114+
FastAppend(&recheck_quals,recheck_qual);
11131115

11141116
ixinfo=lnext(ixinfo);
11151117
}
11161118

1117-
*fixed_indexquals=fixed_quals;
1118-
*recheck_indexquals=recheck_quals;
1119+
*fixed_indexquals=FastListValue(&fixed_quals);
1120+
*recheck_indexquals=FastListValue(&recheck_quals);
11191121
}
11201122

11211123
/*
@@ -1136,10 +1138,12 @@ fix_indxqual_sublist(List *indexqual,
11361138
IndexOptInfo*index,
11371139
List**fixed_quals,List**recheck_quals)
11381140
{
1139-
List*fixed_qual=NIL;
1140-
List*recheck_qual=NIL;
1141+
FastListfixed_qual;
1142+
FastListrecheck_qual;
11411143
List*i;
11421144

1145+
FastListInit(&fixed_qual);
1146+
FastListInit(&recheck_qual);
11431147
foreach(i,indexqual)
11441148
{
11451149
OpExpr*clause= (OpExpr*)lfirst(i);
@@ -1178,19 +1182,18 @@ fix_indxqual_sublist(List *indexqual,
11781182
index,
11791183
&opclass);
11801184

1181-
fixed_qual=lappend(fixed_qual,newclause);
1185+
FastAppend(&fixed_qual,newclause);
11821186

11831187
/*
11841188
* Finally, check to see if index is lossy for this operator. If
11851189
* so, add (a copy of) original form of clause to recheck list.
11861190
*/
11871191
if (op_requires_recheck(newclause->opno,opclass))
1188-
recheck_qual=lappend(recheck_qual,
1189-
copyObject((Node*)clause));
1192+
FastAppend(&recheck_qual,copyObject((Node*)clause));
11901193
}
11911194

1192-
*fixed_quals=fixed_qual;
1193-
*recheck_quals=recheck_qual;
1195+
*fixed_quals=FastListValue(&fixed_qual);
1196+
*recheck_quals=FastListValue(&recheck_qual);
11941197
}
11951198

11961199
staticNode*
@@ -1327,26 +1330,28 @@ get_switched_clauses(List *clauses, Relids outerrelids)
13271330
staticList*
13281331
order_qual_clauses(Query*root,List*clauses)
13291332
{
1330-
List*nosubplans;
1331-
List*withsubplans;
1333+
FastListnosubplans;
1334+
FastListwithsubplans;
13321335
List*l;
13331336

13341337
/* No need to work hard if the query is subselect-free */
13351338
if (!root->hasSubLinks)
13361339
returnclauses;
13371340

1338-
nosubplans=withsubplans=NIL;
1341+
FastListInit(&nosubplans);
1342+
FastListInit(&withsubplans);
13391343
foreach(l,clauses)
13401344
{
13411345
Node*clause=lfirst(l);
13421346

13431347
if (contain_subplans(clause))
1344-
withsubplans=lappend(withsubplans,clause);
1348+
FastAppend(&withsubplans,clause);
13451349
else
1346-
nosubplans=lappend(nosubplans,clause);
1350+
FastAppend(&nosubplans,clause);
13471351
}
13481352

1349-
returnnconc(nosubplans,withsubplans);
1353+
FastConcFast(&nosubplans,&withsubplans);
1354+
returnFastListValue(&nosubplans);
13501355
}
13511356

13521357
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp