OLD | NEW |
1 # 2009 March 28 | 1 # 2009 March 28 |
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 17 matching lines...) Expand all Loading... |
28 # Construct tables | 28 # Construct tables |
29 # | 29 # |
30 do_test tkt3757-1.1 { | 30 do_test tkt3757-1.1 { |
31 db eval { | 31 db eval { |
32 CREATE TABLE t1(x INTEGER, y INTEGER, z TEXT); | 32 CREATE TABLE t1(x INTEGER, y INTEGER, z TEXT); |
33 CREATE INDEX t1i1 ON t1(y,z); | 33 CREATE INDEX t1i1 ON t1(y,z); |
34 INSERT INTO t1 VALUES(1,2,'three'); | 34 INSERT INTO t1 VALUES(1,2,'three'); |
35 CREATE TABLE t2(a INTEGER, b TEXT); | 35 CREATE TABLE t2(a INTEGER, b TEXT); |
36 INSERT INTO t2 VALUES(2, 'two'); | 36 INSERT INTO t2 VALUES(2, 'two'); |
37 ANALYZE; | 37 ANALYZE; |
38 SELECT * FROM sqlite_stat1; | 38 SELECT * FROM sqlite_stat1 ORDER BY 1, 2; |
39 } | 39 } |
40 } {t1 t1i1 {1 1 1}} | 40 } {t1 t1i1 {1 1 1} t2 {} 1} |
41 | 41 |
42 # Modify statistics in order to make the optimizer then that: | 42 # Modify statistics in order to make the optimizer then that: |
43 # | 43 # |
44 # (1) Table T1 has about 250K entries | 44 # (1) Table T1 has about 250K entries |
45 # (2) There are only about 5 distinct values of T1. | 45 # (2) There are only about 5 distinct values of T1. |
46 # | 46 # |
47 # Then run a query with "t1.y IN (SELECT ..)" in the WHERE clause. | 47 # Then run a query with "t1.y IN (SELECT ..)" in the WHERE clause. |
48 # Make sure the index is used. | 48 # Make sure the index is used. |
49 # | 49 # |
50 do_test tkt3757-1.2 { | 50 do_test tkt3757-1.2 { |
51 db eval { | 51 db eval { |
52 DELETE FROM sqlite_stat1; | 52 DELETE FROM sqlite_stat1; |
53 INSERT INTO sqlite_stat1 VALUES('t1','t1i1','250000 50000 30'); | 53 INSERT INTO sqlite_stat1 VALUES('t1','t1i1','250000 50000 30'); |
54 } | 54 } |
55 count_steps { | 55 count_steps { |
56 SELECT * FROM t1 WHERE y IN (SELECT a FROM t2) | 56 SELECT * FROM t1 WHERE y IN (SELECT a FROM t2) |
57 } | 57 } |
58 } {1 2 three scan 0 sort 0} | 58 } {1 2 three scan 0 sort 0} |
59 | 59 |
60 finish_test | 60 finish_test |
OLD | NEW |