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

Commit06a2bae

Browse files
committed
fix garbage paramsel (pathman core)
1 parent625173b commit06a2bae

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

‎src/pg_pathman.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static void handle_binary_opexpr_param(const PartRelationInfo *prel, WrapperNode
8383
staticWrapperNode*handle_opexpr(constOpExpr*expr,WalkerContext*context);
8484
staticWrapperNode*handle_boolexpr(constBoolExpr*expr,WalkerContext*context);
8585
staticWrapperNode*handle_arrexpr(constScalarArrayOpExpr*expr,WalkerContext*context);
86+
staticdoubleestimate_paramsel_using_prel(constPartRelationInfo*prel,intstrategy);
8687
staticRestrictInfo*rebuild_restrictinfo(Node*clause,RestrictInfo*old_rinfo);
8788
staticboolpull_var_param(constWalkerContext*ctx,constOpExpr*expr,Node**var_ptr,Node**param_ptr);
8889

@@ -1189,6 +1190,7 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
11891190
uint32idx=hash_to_part_index(DatumGetInt32(value),
11901191
PrelChildrenCount(prel));
11911192

1193+
result->paramsel=estimate_paramsel_using_prel(prel,strategy);
11921194
result->rangeset=list_make1_irange(make_irange(idx,idx, true));
11931195

11941196
return;/* exit on equal */
@@ -1203,6 +1205,7 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
12031205
PrelChildrenCount(context->prel),
12041206
strategy,
12051207
result);
1208+
result->paramsel=estimate_paramsel_using_prel(prel,strategy);
12061209
return;
12071210
}
12081211

@@ -1237,19 +1240,25 @@ handle_binary_opexpr_param(const PartRelationInfo *prel,
12371240
strategy=get_op_opfamily_strategy(expr->opno,tce->btree_opf);
12381241

12391242
result->rangeset=list_make1_irange(make_irange(0,PrelLastChild(prel), true));
1243+
result->paramsel=estimate_paramsel_using_prel(prel,strategy);
1244+
}
12401245

1246+
/*
1247+
* Extracted common 'paramsel' estimator.
1248+
*/
1249+
staticdouble
1250+
estimate_paramsel_using_prel(constPartRelationInfo*prel,intstrategy)
1251+
{
1252+
/* If it's "=", divide by partitions number */
12411253
if (strategy==BTEqualStrategyNumber)
1242-
{
1243-
result->paramsel=1.0 / (double)PrelChildrenCount(prel);
1244-
}
1254+
return1.0 / (double)PrelChildrenCount(prel);
1255+
1256+
/* Default selectivity estimate for inequalities */
12451257
elseif (prel->parttype==PT_RANGE&&strategy>0)
1246-
{
1247-
result->paramsel=DEFAULT_INEQ_SEL;
1248-
}
1249-
else
1250-
{
1251-
result->paramsel=1.0;
1252-
}
1258+
returnDEFAULT_INEQ_SEL;
1259+
1260+
/* Else there's not much to do */
1261+
elsereturn1.0;
12531262
}
12541263

12551264
/*
@@ -1324,6 +1333,7 @@ handle_const(const Const *c, WalkerContext *context)
13241333
{
13251334
constPartRelationInfo*prel=context->prel;
13261335
WrapperNode*result= (WrapperNode*)palloc(sizeof(WrapperNode));
1336+
intstrategy=BTEqualStrategyNumber;
13271337

13281338
result->orig= (constNode*)c;
13291339

@@ -1348,6 +1358,8 @@ handle_const(const Const *c, WalkerContext *context)
13481358
Datumvalue=OidFunctionCall1(prel->hash_proc,c->constvalue);
13491359
uint32idx=hash_to_part_index(DatumGetInt32(value),
13501360
PrelChildrenCount(prel));
1361+
1362+
result->paramsel=estimate_paramsel_using_prel(prel,strategy);
13511363
result->rangeset=list_make1_irange(make_irange(idx,idx, true));
13521364
}
13531365
break;
@@ -1362,8 +1374,10 @@ handle_const(const Const *c, WalkerContext *context)
13621374
&tce->cmp_proc_finfo,
13631375
PrelGetRangesArray(context->prel),
13641376
PrelChildrenCount(context->prel),
1365-
BTEqualStrategyNumber,
1377+
strategy,
13661378
result);
1379+
1380+
result->paramsel=estimate_paramsel_using_prel(prel,strategy);
13671381
}
13681382
break;
13691383

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp