[Groonga-commit] pgroonga/pgroonga at 685b329 [master] Improve estimation index search with IMMUTABLE/STABLE function call

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Oct 7 13:42:41 JST 2017


Kouhei Sutou	2017-10-07 13:42:41 +0900 (Sat, 07 Oct 2017)

  New Revision: 685b329b6e4e86966714ed24d10ceb77a0e301f2
  https://github.com/pgroonga/pgroonga/commit/685b329b6e4e86966714ed24d10ceb77a0e301f2

  Message:
    Improve estimation index search with IMMUTABLE/STABLE function call

  Modified files:
    src/pgroonga.c

  Modified: src/pgroonga.c (+7 -4)
===================================================================
--- src/pgroonga.c    2017-10-05 16:49:53 +0900 (f9ee1a9)
+++ src/pgroonga.c    2017-10-07 13:42:41 +0900 (7e94b02)
@@ -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;
@@ -5032,6 +5032,7 @@ PGrnCostEstimateUpdateSelectivity(IndexPath *path)
 		Oid rightType;
 		Node *leftNode;
 		Node *rightNode;
+		Node *estimatedRightNode;
 		Var *var;
 		int nthAttribute = InvalidAttrNumber;
 		Oid opFamily = InvalidOid;
@@ -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;
@@ -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))
 		{
@@ -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,
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171007/4d3bc127/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index