1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

The optimizer now uses only the index and ignores the table if it can get

away with doing so, thus saving a single BTree search per row of result.
This could potentially double the speed of certain queries.  The
code passes all regression tests but new tests to exercise the new
functionality are yet to be added. (CVS 2170)

FossilOrigin-Name: e5aa489453bf31126da6473ef93c89ec27935cde
This commit is contained in:
drh
2004-12-19 00:11:35 +00:00
parent 51669863a8
commit 9012bcbc0a
7 changed files with 255 additions and 258 deletions

View File

@ -12,7 +12,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
# $Id: collate4.test,v 1.5 2004/11/22 19:12:21 drh Exp $
# $Id: collate4.test,v 1.6 2004/12/19 00:11:36 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -351,7 +351,7 @@ do_test collate4-2.1.2 {
count {
SELECT * FROM collate4t2, collate4t1 WHERE a = b;
}
} {A a A A 7}
} {A a A A 5}
do_test collate4-2.1.3 {
count {
SELECT * FROM collate4t2, collate4t1 WHERE b = a;
@ -370,7 +370,7 @@ do_test collate4-2.1.5 {
count {
SELECT * FROM collate4t2, collate4t1 WHERE b = a;
}
} {A A 5}
} {A A 4}
do_test collate4-2.1.6 {
count {
SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2);
@ -384,12 +384,12 @@ do_test collate4-2.1.7 {
count {
SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2);
}
} {a A 8}
} {a A 6}
do_test collate4-2.1.8 {
count {
SELECT a FROM collate4t1 WHERE a IN ('z', 'a');
}
} {a A 7}
} {a A 5}
do_test collate4-2.1.9 {
execsql {
DROP INDEX collate4i1;
@ -427,14 +427,14 @@ do_test collate4-2.2.1 {
SELECT * FROM collate4t2 NATURAL JOIN collate4t1;
}
} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 63}
do_test collate4-2.2.1 {
do_test collate4-2.2.1b {
execsql {
CREATE INDEX collate4i1 ON collate4t1(a, b, c);
}
count {
SELECT * FROM collate4t2 NATURAL JOIN collate4t1;
}
} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 45}
} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 29}
do_test collate4-2.2.2 {
execsql {
DROP INDEX collate4i1;

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the use of indices in WHERE clases.
#
# $Id: where.test,v 1.25 2004/12/18 18:40:28 drh Exp $
# $Id: where.test,v 1.26 2004/12/19 00:11:36 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -151,35 +151,35 @@ do_test where-1.29 {
do_test where-1.30 {
count {SELECT w FROM t1 WHERE w>97}
} {98 99 100 6}
} {98 99 100 3}
do_test where-1.31 {
count {SELECT w FROM t1 WHERE w>=97}
} {97 98 99 100 8}
} {97 98 99 100 4}
do_test where-1.33 {
count {SELECT w FROM t1 WHERE w==97}
} {97 3}
} {97 2}
do_test where-1.34 {
count {SELECT w FROM t1 WHERE w+1==98}
} {97 99}
do_test where-1.35 {
count {SELECT w FROM t1 WHERE w<3}
} {1 2 4}
} {1 2 2}
do_test where-1.36 {
count {SELECT w FROM t1 WHERE w<=3}
} {1 2 3 6}
} {1 2 3 3}
do_test where-1.37 {
count {SELECT w FROM t1 WHERE w+1<=4 ORDER BY w}
} {1 2 3 199}
} {1 2 3 99}
do_test where-1.38 {
count {SELECT (w) FROM t1 WHERE (w)>(97)}
} {98 99 100 6}
} {98 99 100 3}
do_test where-1.39 {
count {SELECT (w) FROM t1 WHERE (w)>=(97)}
} {97 98 99 100 8}
} {97 98 99 100 4}
do_test where-1.40 {
count {SELECT (w) FROM t1 WHERE (w)==(97)}
} {97 3}
} {97 2}
do_test where-1.41 {
count {SELECT (w) FROM t1 WHERE ((w)+(1))==(98)}
} {97 99}
@ -237,19 +237,19 @@ do_test where-3.1 {
SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=11
}
} {11 90 11 9}
} {11 90 11 8}
do_test where-3.2 {
count {
SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=12
}
} {12 89 12 9}
} {12 89 12 8}
do_test where-3.3 {
count {
SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C
WHERE A.w=15 AND B.p=C.w AND B.r=10202-A.y
}
} {15 86 86 9}
} {15 86 86 8}
# Test to see that the special case of a constant WHERE clause is
# handled.
@ -417,7 +417,7 @@ do_test where-6.8 {
cksort {
SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a LIMIT 3
}
} {1 100 4 2 99 9 3 98 16 nosort}
} {1 100 4 2 99 9 3 98 16 sort}
do_test where-6.9.1 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3
@ -457,12 +457,12 @@ do_test where-6.9.8 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c ASC LIMIT 3
}
} {1 100 4 sort}
} {1 100 4 nosort}
do_test where-6.9.9 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a ASC, c DESC LIMIT 3
}
} {1 100 4 sort}
} {1 100 4 nosort}
do_test where-6.10 {
cksort {
SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3