9
9
*
10
10
*
11
11
* IDENTIFICATION
12
- * $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.25 2009/05/10 22:45:28 tgl Exp $
12
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.26 2009/05/11 17:56:08 tgl Exp $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
31
31
32
32
33
33
/*
34
- * Proof attempts involvingmany AND or OR branches are likely to require
35
- * O(N^2) time, and more often than not fail anyway. So we set an arbitrary
36
- * limit on the number ofbranches that we will allow at any one level of
37
- *clause. (Note that this is only effective because the trees have been
38
- *AND/OR flattened!) XXX is it worth exposing this as a GUC knob?
34
+ * Proof attempts involvinglarge arrays in ScalarArrayOpExpr nodes are
35
+ *likely to require O(N^2) time, and more often than not fail anyway.
36
+ *So we set an arbitrary limit on the number ofarray elements that
37
+ *we will allow to be treated as an AND or OR clause.
38
+ * XXX is it worth exposing this as a GUC knob?
39
39
*/
40
- #define MAX_BRANCHES_TO_TEST 100
40
+ #define MAX_SAOP_ARRAY_SIZE 100
41
41
42
42
/*
43
43
* To avoid redundant coding in predicate_implied_by_recurse and
@@ -735,12 +735,12 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
735
735
* If the expression is classified as AND- or OR-type, then *info is filled
736
736
* in with the functions needed to iterate over its components.
737
737
*
738
- * This function also implements enforcement ofMAX_BRANCHES_TO_TEST : ifan
739
- *AND/OR expression has too manybranches , we just classify it as an atom.
740
- * (This will result in its being passed as-is to the simple_clause functions,
741
- * which will fail to prove anything about it.) Note that we cannot just stop
742
- * after consideringMAX_BRANCHES_TO_TEST branches ; in general that would
743
- * result in wrong proofs rather than failing to prove anything.
738
+ * This function also implements enforcement ofMAX_SAOP_ARRAY_SIZE : ifa
739
+ *ScalarArrayOpExpr's array has too manyelements , we just classify it as an
740
+ *atom. (This will result in its being passed as-is to the simple_clause
741
+ *functions, which will fail to prove anything about it.) Note that we
742
+ *cannot just stop after consideringMAX_SAOP_ARRAY_SIZE elements ; in general
743
+ *that would result in wrong proofs, rather than failing to prove anything.
744
744
*/
745
745
static PredClass
746
746
predicate_classify (Node * clause ,PredIterInfo info )
@@ -753,8 +753,7 @@ predicate_classify(Node *clause, PredIterInfo info)
753
753
* If we see a List, assume it's an implicit-AND list; this is the correct
754
754
* semantics for lists of RestrictInfo nodes.
755
755
*/
756
- if (IsA (clause ,List )&&
757
- list_length ((List * )clause ) <=MAX_BRANCHES_TO_TEST )
756
+ if (IsA (clause ,List ))
758
757
{
759
758
info -> startup_fn = list_startup_fn ;
760
759
info -> next_fn = list_next_fn ;
@@ -763,16 +762,14 @@ predicate_classify(Node *clause, PredIterInfo info)
763
762
}
764
763
765
764
/* Handle normal AND and OR boolean clauses */
766
- if (and_clause (clause )&&
767
- list_length (((BoolExpr * )clause )-> args ) <=MAX_BRANCHES_TO_TEST )
765
+ if (and_clause (clause ))
768
766
{
769
767
info -> startup_fn = boolexpr_startup_fn ;
770
768
info -> next_fn = list_next_fn ;
771
769
info -> cleanup_fn = list_cleanup_fn ;
772
770
return CLASS_AND ;
773
771
}
774
- if (or_clause (clause )&&
775
- list_length (((BoolExpr * )clause )-> args ) <=MAX_BRANCHES_TO_TEST )
772
+ if (or_clause (clause ))
776
773
{
777
774
info -> startup_fn = boolexpr_startup_fn ;
778
775
info -> next_fn = list_next_fn ;
@@ -800,7 +797,7 @@ predicate_classify(Node *clause, PredIterInfo info)
800
797
801
798
arrayval = DatumGetArrayTypeP (((Const * )arraynode )-> constvalue );
802
799
nelems = ArrayGetNItems (ARR_NDIM (arrayval ),ARR_DIMS (arrayval ));
803
- if (nelems <=MAX_BRANCHES_TO_TEST )
800
+ if (nelems <=MAX_SAOP_ARRAY_SIZE )
804
801
{
805
802
info -> startup_fn = arrayconst_startup_fn ;
806
803
info -> next_fn = arrayconst_next_fn ;
@@ -810,7 +807,7 @@ predicate_classify(Node *clause, PredIterInfo info)
810
807
}
811
808
else if (arraynode && IsA (arraynode ,ArrayExpr )&&
812
809
!((ArrayExpr * )arraynode )-> multidims &&
813
- list_length (((ArrayExpr * )arraynode )-> elements ) <=MAX_BRANCHES_TO_TEST )
810
+ list_length (((ArrayExpr * )arraynode )-> elements ) <=MAX_SAOP_ARRAY_SIZE )
814
811
{
815
812
info -> startup_fn = arrayexpr_startup_fn ;
816
813
info -> next_fn = arrayexpr_next_fn ;