OLD | NEW |
1 # 2011 August 13 | 1 # 2011 August 13 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}} | 79 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}} |
80 do_test 2.1 { | 80 do_test 2.1 { |
81 eqp {SELECT * FROM t1 WHERE a=100 AND b BETWEEN 50 AND 54} | 81 eqp {SELECT * FROM t1 WHERE a=100 AND b BETWEEN 50 AND 54} |
82 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}} | 82 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}} |
83 | 83 |
84 # There are many more values of c between 0 and 100000 than there are | 84 # There are many more values of c between 0 and 100000 than there are |
85 # between 800000 and 900000. So t1c is more selective for the latter | 85 # between 800000 and 900000. So t1c is more selective for the latter |
86 # range. | 86 # range. |
87 # | 87 # |
88 # Test 3.2 is a little unstable. It depends on the planner estimating | 88 # Test 3.2 is a little unstable. It depends on the planner estimating |
89 # that (b BETWEEN 50 AND 54) will match more rows than (c BETWEEN | 89 # that (b BETWEEN 30 AND 34) will match more rows than (c BETWEEN |
90 # 800000 AND 900000). Which is a pretty close call (50 vs. 32), so | 90 # 800000 AND 900000). Which is a pretty close call (50 vs. 32), so |
91 # the planner could get it wrong with an unlucky set of samples. This | 91 # the planner could get it wrong with an unlucky set of samples. This |
92 # case happens to work, but others ("b BETWEEN 40 AND 44" for example) | 92 # case happens to work, but others ("b BETWEEN 40 AND 44" for example) |
93 # will fail. | 93 # will fail. |
94 # | 94 # |
95 do_execsql_test 3.0 { | 95 do_execsql_test 3.0 { |
96 SELECT count(*) FROM t1 WHERE b BETWEEN 50 AND 54; | 96 SELECT count(*) FROM t1 WHERE b BETWEEN 30 AND 34; |
97 SELECT count(*) FROM t1 WHERE c BETWEEN 0 AND 100000; | 97 SELECT count(*) FROM t1 WHERE c BETWEEN 0 AND 100000; |
98 SELECT count(*) FROM t1 WHERE c BETWEEN 800000 AND 900000; | 98 SELECT count(*) FROM t1 WHERE c BETWEEN 800000 AND 900000; |
99 } {50 376 32} | 99 } {50 376 32} |
100 do_test 3.1 { | 100 do_test 3.1 { |
101 eqp {SELECT * FROM t1 WHERE b BETWEEN 50 AND 54 AND c BETWEEN 0 AND 100000} | 101 eqp {SELECT * FROM t1 WHERE b BETWEEN 30 AND 34 AND c BETWEEN 0 AND 100000} |
102 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}} | 102 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}} |
103 do_test 3.2 { | 103 do_test 3.2 { |
104 eqp {SELECT * FROM t1 | 104 eqp {SELECT * FROM t1 |
105 WHERE b BETWEEN 50 AND 54 AND c BETWEEN 800000 AND 900000} | 105 WHERE b BETWEEN 30 AND 34 AND c BETWEEN 800000 AND 900000} |
106 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}} | 106 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}} |
107 do_test 3.3 { | 107 do_test 3.3 { |
108 eqp {SELECT * FROM t1 WHERE a=100 AND c BETWEEN 0 AND 100000} | 108 eqp {SELECT * FROM t1 WHERE a=100 AND c BETWEEN 0 AND 100000} |
109 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}} | 109 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}} |
110 do_test 3.4 { | 110 do_test 3.4 { |
111 eqp {SELECT * FROM t1 | 111 eqp {SELECT * FROM t1 |
112 WHERE a=100 AND c BETWEEN 800000 AND 900000} | 112 WHERE a=100 AND c BETWEEN 800000 AND 900000} |
113 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}} | 113 } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}} |
114 | 114 |
115 finish_test | 115 finish_test |
OLD | NEW |