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

Commit105c149

Browse files
committed
check restrInfo->required_relids in order to discard irrelevant joins
1 parent971d2c5 commit105c149

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

‎init.c‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ join_pathlist_hook(PlannerInfo *root,
117117
text*dist_func_name=cstring_to_text("dist(spoint,spoint)");
118118
Oiddist_func;
119119
List*restrict_clauses=extra->restrictlist;
120+
Relidsrequired_relids=NULL;
121+
122+
if (outerrel->reloptkind==RELOPT_BASEREL&&
123+
innerrel->reloptkind==RELOPT_BASEREL)
124+
{
125+
required_relids=bms_add_member(required_relids,outerrel->relid);
126+
required_relids=bms_add_member(required_relids,innerrel->relid);
127+
}
128+
elsereturn;/* one of relations can't have index */
120129

121130
dist_func=DatumGetObjectId(DirectFunctionCall1(to_regprocedure,
122131
PointerGetDatum(dist_func_name)));
@@ -136,14 +145,9 @@ join_pathlist_hook(PlannerInfo *root,
136145
{
137146
RestrictInfo*restrInfo= (RestrictInfo*)lfirst(restr);
138147

139-
if (outerrel->reloptkind==RELOPT_BASEREL&&
140-
innerrel->reloptkind==RELOPT_BASEREL&&
141-
bms_is_member(outerrel->relid,restrInfo->clause_relids)&&
142-
bms_is_member(innerrel->relid,restrInfo->clause_relids))
143-
{
144-
/* This is our case */
145-
}
146-
elsecontinue;
148+
/* Skip irrelevant JOIN case */
149+
if (!bms_equal(required_relids,restrInfo->required_relids))
150+
continue;
147151

148152
if (IsA(restrInfo->clause,OpExpr))
149153
{
@@ -176,7 +180,6 @@ join_pathlist_hook(PlannerInfo *root,
176180
required_outer,
177181
&restrict_clauses);
178182

179-
/* DEBUG */
180183
create_crossmatch_path(root,joinrel,outer_path,inner_path,
181184
param_info,restrict_clauses,required_outer);
182185

@@ -187,6 +190,7 @@ join_pathlist_hook(PlannerInfo *root,
187190
IsA(arg2,FuncExpr)&&
188191
((FuncExpr*)arg2)->funcid==dist_func)
189192
{
193+
/* TODO: merge duplicate code */
190194
Path*outer_path=crossmatch_find_cheapest_path(root,joinrel,outerrel);
191195
Path*inner_path=crossmatch_find_cheapest_path(root,joinrel,innerrel);
192196

@@ -200,14 +204,11 @@ join_pathlist_hook(PlannerInfo *root,
200204
required_outer,
201205
&restrict_clauses);
202206

203-
/* DEBUG */
204207
create_crossmatch_path(root,joinrel,outer_path,inner_path,
205208
param_info,restrict_clauses,required_outer);
206209
}
207210
}
208211
}
209-
210-
pprint(root->parse->rtable);
211212
}
212213

213214
staticPlan*
@@ -241,7 +242,7 @@ create_crossmatch_plan(PlannerInfo *root,
241242
cscan->scan.plan.qual=NIL;
242243
cscan->scan.scanrelid=0;
243244

244-
cscan->custom_scan_tlist=tlist;
245+
cscan->custom_scan_tlist=tlist;/* TODO: recheck target list */
245246

246247
elog(LOG,"tlist:");
247248
pprint(tlist);
@@ -268,6 +269,7 @@ crossmatch_create_scan_state(CustomScan *node)
268269
return (Node*)scan_state;
269270
}
270271

272+
/* HACK: remove this */
271273
staticinti=0;
272274

273275
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp