Navigation Menu

Skip to content

Commit

Permalink
Improve estimation index search with IMMUTABLE/STABLE function call
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 7, 2017
1 parent 04b7ddf commit 685b329
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pgroonga.c
Expand Up @@ -5011,7 +5011,7 @@ pgroonga_canreturn(PG_FUNCTION_ARGS)
}

static void
PGrnCostEstimateUpdateSelectivity(IndexPath *path)
PGrnCostEstimateUpdateSelectivity(PlannerInfo *root, IndexPath *path)
{
IndexOptInfo *indexInfo = path->indexinfo;
Relation index;
Expand All @@ -5032,6 +5032,7 @@ PGrnCostEstimateUpdateSelectivity(IndexPath *path)
Oid rightType;
Node *leftNode;
Node *rightNode;
Node *estimatedRightNode;
Var *var;
int nthAttribute = InvalidAttrNumber;
Oid opFamily = InvalidOid;
Expand All @@ -5053,7 +5054,9 @@ PGrnCostEstimateUpdateSelectivity(IndexPath *path)

if (!IsA(leftNode, Var))
continue;
if (!IsA(rightNode, Const))

estimatedRightNode = estimate_expression_value(root, rightNode);
if (!IsA(estimatedRightNode, Const))
continue;

var = (Var *) leftNode;
Expand Down Expand Up @@ -5083,7 +5086,7 @@ PGrnCostEstimateUpdateSelectivity(IndexPath *path)
key.sk_flags = 0;
key.sk_attno = nthAttribute;
key.sk_strategy = strategy;
key.sk_argument = ((Const *) rightNode)->constvalue;
key.sk_argument = ((Const *) estimatedRightNode)->constvalue;
PGrnSearchDataInit(&data, sourcesTable);
if (PGrnSearchBuildCondition(index, &key, &data))
{
Expand Down Expand Up @@ -5138,7 +5141,7 @@ pgroonga_costestimate_raw(PlannerInfo *root,
#endif
)
{
PGrnCostEstimateUpdateSelectivity(path);
PGrnCostEstimateUpdateSelectivity(root, path);
*indexSelectivity = clauselist_selectivity(root,
path->indexquals,
path->indexinfo->rel->relid,
Expand Down

0 comments on commit 685b329

Please sign in to comment.