Created
July 1, 2013 14:56
-
-
Save RhodiumToad/5901567 to your computer and use it in GitHub Desktop.
suggested fix for boolean selectivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c | |
index da66f34..4e8f3f2 100644 | |
--- a/src/backend/utils/adt/selfuncs.c | |
+++ b/src/backend/utils/adt/selfuncs.c | |
@@ -1549,11 +1549,17 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, | |
selec = 1.0 - freq_null; | |
break; | |
case IS_TRUE: | |
- case IS_NOT_TRUE: | |
case IS_FALSE: | |
- case IS_NOT_FALSE: | |
selec = (1.0 - freq_null) / 2.0; | |
break; | |
+ case IS_NOT_TRUE: | |
+ case IS_NOT_FALSE: | |
+ /* | |
+ * include the null values plus half of the non-null ones. | |
+ * equiv. to freq_null + (1.0 - freq_null)/2.0 | |
+ */ | |
+ selec = (freq_null + 1.0) / 2.0; | |
+ break; | |
default: | |
elog(ERROR, "unrecognized booltesttype: %d", | |
(int) booltesttype); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment