Add additional test cases for skip-scan.
FossilOrigin-Name: 1ae4915d4d08ee5ce526c04d1d0cda1078641793
This commit is contained in:
parent
ef1bd970ef
commit
21236679d1
11
manifest
11
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sadditional\stest\scases\sand\srequirements\sevidence\smarks\sfor\sWITHOUT\sROWID.
|
||||
D 2013-11-27T00:45:49.889
|
||||
C Add\sadditional\stest\scases\sfor\sskip-scan.
|
||||
D 2013-11-27T01:23:53.318
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -808,6 +808,7 @@ F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
|
||||
F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868
|
||||
F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329
|
||||
F test/skipscan1.test 6bb4891c2cc5efd5690a9da9e7508e53d4a68e10
|
||||
F test/skipscan2.test c1e21a19ec8fa3674e9ccd0475f20ef82c275838
|
||||
F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f
|
||||
F test/softheap1.test 40562fe6cac6d9827b7b42b86d45aedf12c15e24
|
||||
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
|
||||
@ -1144,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||
P 0978bac6b8aee229d7a0d148546f50d380d06a06
|
||||
R c5e238577bf88ba62aaf207d6ba68ed5
|
||||
P b408d788105efd007e3546f45d5dd15a5dc5688d
|
||||
R d4fd41c1f94c9f73ab9606b0e58d8a6b
|
||||
U drh
|
||||
Z 6729df1882fbf26a3a642e6e52bb3ce5
|
||||
Z 5fe0b4019eaac7439aed9d81168a0a2a
|
||||
|
@ -1 +1 @@
|
||||
b408d788105efd007e3546f45d5dd15a5dc5688d
|
||||
1ae4915d4d08ee5ce526c04d1d0cda1078641793
|
150
test/skipscan2.test
Normal file
150
test/skipscan2.test
Normal file
@ -0,0 +1,150 @@
|
||||
# 2013-11-27
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements tests of the "skip-scan" query strategy.
|
||||
#
|
||||
# The test cases in this file are derived from the description of
|
||||
# the skip-scan query strategy in the "optoverview.html" document.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_execsql_test skipscan2-1.1 {
|
||||
CREATE TABLE people(
|
||||
name TEXT PRIMARY KEY,
|
||||
role TEXT NOT NULL,
|
||||
height INT NOT NULL, -- in cm
|
||||
CHECK( role IN ('student','teacher') )
|
||||
);
|
||||
CREATE INDEX people_idx1 ON people(role, height);
|
||||
} {}
|
||||
do_execsql_test skipscan2-1.2 {
|
||||
INSERT INTO people VALUES('Alice','student',156);
|
||||
INSERT INTO people VALUES('Bob','student',161);
|
||||
INSERT INTO people VALUES('Cindy','student',155);
|
||||
INSERT INTO people VALUES('David','student',181);
|
||||
INSERT INTO people VALUES('Emily','teacher',158);
|
||||
INSERT INTO people VALUES('Fred','student',163);
|
||||
INSERT INTO people VALUES('Ginny','student',169);
|
||||
INSERT INTO people VALUES('Harold','student',172);
|
||||
INSERT INTO people VALUES('Imma','student',179);
|
||||
INSERT INTO people VALUES('Jack','student',181);
|
||||
INSERT INTO people VALUES('Karen','student',163);
|
||||
INSERT INTO people VALUES('Logan','student',177);
|
||||
INSERT INTO people VALUES('Megan','teacher',159);
|
||||
INSERT INTO people VALUES('Nathan','student',163);
|
||||
INSERT INTO people VALUES('Olivia','student',161);
|
||||
INSERT INTO people VALUES('Patrick','teacher',180);
|
||||
INSERT INTO people VALUES('Quiana','student',182);
|
||||
INSERT INTO people VALUES('Robert','student',159);
|
||||
INSERT INTO people VALUES('Sally','student',166);
|
||||
INSERT INTO people VALUES('Tom','student',171);
|
||||
INSERT INTO people VALUES('Ursula','student',170);
|
||||
INSERT INTO people VALUES('Vance','student',179);
|
||||
INSERT INTO people VALUES('Willma','student',175);
|
||||
INSERT INTO people VALUES('Xavier','teacher',185);
|
||||
INSERT INTO people VALUES('Yvonne','student',149);
|
||||
INSERT INTO people VALUES('Zach','student',170);
|
||||
}
|
||||
|
||||
# Without ANALYZE, a skip-scan is not used
|
||||
#
|
||||
do_execsql_test skipscan2-1.3 {
|
||||
SELECT name FROM people WHERE height>=180 ORDER BY +name;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
do_execsql_test skipscan2-1.3eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT name FROM people WHERE height>=180 ORDER BY +name;
|
||||
} {~/*INDEX people_idx1 */}
|
||||
|
||||
# Now do an ANALYZE. A skip-scan can be used after ANALYZE.
|
||||
#
|
||||
do_execsql_test skipscan2-1.4 {
|
||||
ANALYZE;
|
||||
-- We do not have enough people above to actually force the use
|
||||
-- of a skip-scan. So make a manual adjustment to the stat1 table
|
||||
-- to make it seem like there are many more.
|
||||
UPDATE sqlite_stat1 SET stat='10000 5000 20' WHERE idx='people_idx1';
|
||||
ANALYZE sqlite_master;
|
||||
}
|
||||
db cache flush
|
||||
do_execsql_test skipscan2-1.5 {
|
||||
SELECT name FROM people WHERE height>=180 ORDER BY +name;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
do_execsql_test skipscan2-1.5eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT name FROM people WHERE height>=180 ORDER BY +name;
|
||||
} {/*INDEX people_idx1 */}
|
||||
|
||||
# Same answer with other formulations of the same query
|
||||
#
|
||||
do_execsql_test skipscan2-1.6 {
|
||||
SELECT name FROM people
|
||||
WHERE role IN (SELECT DISTINCT role FROM people)
|
||||
AND height>=180 ORDER BY +name;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
do_execsql_test skipscan2-1.7 {
|
||||
SELECT name FROM people WHERE role='teacher' AND height>=180
|
||||
UNION ALL
|
||||
SELECT name FROM people WHERE role='student' AND height>=180
|
||||
ORDER BY 1;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
|
||||
# Repeat using a WITHOUT ROWID table.
|
||||
#
|
||||
do_execsql_test skipscan2-2.1 {
|
||||
CREATE TABLE peoplew(
|
||||
name TEXT PRIMARY KEY,
|
||||
role TEXT NOT NULL,
|
||||
height INT NOT NULL, -- in cm
|
||||
CHECK( role IN ('student','teacher') )
|
||||
) WITHOUT ROWID;
|
||||
CREATE INDEX peoplew_idx1 ON peoplew(role, height);
|
||||
INSERT INTO peoplew(name,role,height)
|
||||
SELECT name, role, height FROM people;
|
||||
DROP TABLE people;
|
||||
SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
do_execsql_test skipscan2-2.2 {
|
||||
SELECT name FROM peoplew
|
||||
WHERE role IN (SELECT DISTINCT role FROM peoplew)
|
||||
AND height>=180 ORDER BY +name;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
do_execsql_test skipscan2-2.2 {
|
||||
SELECT name FROM peoplew WHERE role='teacher' AND height>=180
|
||||
UNION ALL
|
||||
SELECT name FROM peoplew WHERE role='student' AND height>=180
|
||||
ORDER BY 1;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
|
||||
# Now do an ANALYZE. A skip-scan can be used after ANALYZE.
|
||||
#
|
||||
do_execsql_test skipscan2-2.4 {
|
||||
ANALYZE;
|
||||
-- We do not have enough people above to actually force the use
|
||||
-- of a skip-scan. So make a manual adjustment to the stat1 table
|
||||
-- to make it seem like there are many more.
|
||||
UPDATE sqlite_stat1 SET stat='10000 5000 20' WHERE idx='peoplew_idx1';
|
||||
ANALYZE sqlite_master;
|
||||
}
|
||||
db cache flush
|
||||
do_execsql_test skipscan2-2.5 {
|
||||
SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;
|
||||
} {David Jack Patrick Quiana Xavier}
|
||||
do_execsql_test skipscan2-2.5eqp {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;
|
||||
} {/*INDEX peoplew_idx1 */}
|
||||
|
||||
|
||||
|
||||
finish_test
|
Loading…
x
Reference in New Issue
Block a user