1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Use the cache with loading a large table in select2-2.0. (CVS 2272)

FossilOrigin-Name: bd65b1805c116a9073a01164d77e2bfd4ab3b447
This commit is contained in:
drh
2005-01-24 12:46:14 +00:00
parent a21c6b6fe0
commit 190765c470
3 changed files with 45 additions and 16 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the SELECT statement.
#
# $Id: select2.test,v 1.22 2004/05/28 11:37:29 danielk1977 Exp $
# $Id: select2.test,v 1.23 2005/01/24 12:46:14 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -56,15 +56,44 @@ do_test select2-1.2 {
set r
} {4: 2 3 4}
# Create a largish table
# Create a largish table. Do this twice, once using the TCL cache and once
# without. Compare the performance to make sure things go faster with the
# cache turned on.
#
do_test select2-2.0 {
execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}
for {set i 1} {$i<=30000} {incr i} {
execsql "INSERT INTO tbl2 VALUES($i,[expr {$i*2}],[expr {$i*3}])"
}
execsql {COMMIT}
ifcapable tclvar {
do_test select2-2.0.1 {
set t1 [time {
execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}
for {set i 1} {$i<=30000} {incr i} {
set i2 [expr {$i*2}]
set i3 [expr {$i*3}]
db eval {INSERT INTO tbl2 VALUES($i,$i2,$i3)}
}
execsql {COMMIT}
}]
set result {}
} {}
puts "time with cache: $::t1"
}
catch {execsql {DROP TABLE tbl2}}
do_test select2-2.0.2 {
set t2 [time {
execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}
for {set i 1} {$i<=30000} {incr i} {
set i2 [expr {$i*2}]
set i3 [expr {$i*3}]
execsql "INSERT INTO tbl2 VALUES($i,$i2,$i3)"
}
execsql {COMMIT}
}]
set result {}
} {}
puts "time without cache: $t2"
ifcapable tclvar {
do_test select2-2.0.3 {
expr {[lindex $t1 0]<[lindex $t2 0]}
} 1
}
do_test select2-2.1 {
execsql {SELECT count(*) FROM tbl2}