]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add test cases that compare the performance of the transitive_closure
authordrh <drh@noemail.net>
Fri, 24 Jan 2014 14:37:44 +0000 (14:37 +0000)
committerdrh <drh@noemail.net>
Fri, 24 Jan 2014 14:37:44 +0000 (14:37 +0000)
virtual table again common table expressions for walking a tree.

FossilOrigin-Name: 9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222

manifest
manifest.uuid
test/closure01.test
test/tester.tcl

index fb401ca29f337f6bb29c64ce58253b0616424355..2336aab937b7096accedd9b0ebe0c961ec73ee8e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stest\scases\sshowing\sthe\suse\sof\sORDER\sBY\son\sa\srecursive\squery\sto\scontrol\ndepth-first\sversus\sbreath-first\ssearch\sof\sa\stree.
-D 2014-01-24T11:16:01.884
+C Add\stest\scases\sthat\scompare\sthe\sperformance\sof\sthe\stransitive_closure\nvirtual\stable\sagain\scommon\stable\sexpressions\sfor\swalking\sa\stree.
+D 2014-01-24T14:37:44.938
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -372,7 +372,7 @@ F test/capi3e.test ad90088b18b0367125ff2d4b5400153fd2f99aab
 F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3
 F test/check.test 5831ddb6f2c687782eaf2e1a07b6e17f24c4f763
 F test/close.test 340bd24cc58b16c6bc01967402755027c37eb815
-F test/closure01.test dbb28f1ea9eeaf0a53ec5bc0fed352e479def8c7
+F test/closure01.test 52036bd5f5d1734f41ba708e9038198aa274156a
 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
 F test/collate1.test 73b91005f264b7c403e2d63a6708d150679ac99a
 F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621
@@ -844,7 +844,7 @@ F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43
 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
-F test/tester.tcl 08e9f317afe60d398fa900993503ecaef3295bad
+F test/tester.tcl 9bd04481b8b0ef1f2049ad01f28e175ee9a14f7b
 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P f4a701d55f5c4e1e62ed64b779ad4fff89dd31b7
-R 15c1d48ec007e0818a79a87f9c81fe3d
+P 83b0b2916589db0184435dbd4c304387f393ed60
+R f85f8ae6263bf3d6f45ffff44c95c74a
 U drh
-Z a61c87789af8810b68d544f76885410e
+Z be990f0e27dcbfb4abd20beb041780d7
index 1c78fab271e5baa2d2d02aeb5a3f0116d1c95988..cc3b6b68307b6b52a80add5b41610f6037113ea5 100644 (file)
@@ -1 +1 @@
-83b0b2916589db0184435dbd4c304387f393ed60
\ No newline at end of file
+9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222
\ No newline at end of file
index 5dac87a0ce28446a818858daab515af3a150949c..346ea76e8c444b175e5f49562d3e2fd207558b20 100644 (file)
@@ -15,41 +15,36 @@ set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 set testprefix closure01
 
-ifcapable !vtab { finish_test ; return }
+ifcapable !vtab||!cte { finish_test ; return }
 
 load_static_extension db closure
 
 do_execsql_test 1.0 {
   BEGIN;
   CREATE TABLE t1(x INTEGER PRIMARY KEY, y INTEGER);
+  WITH RECURSIVE
+    cnt(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM cnt LIMIT 131072)
+  INSERT INTO t1(x, y) SELECT i, nullif(i,1)/2 FROM cnt;
   CREATE INDEX t1y ON t1(y);
-  INSERT INTO t1(x) VALUES(1),(2);
-  INSERT INTO t1(x) SELECT x+2 FROM t1;
-  INSERT INTO t1(x) SELECT x+4 FROM t1;
-  INSERT INTO t1(x) SELECT x+8 FROM t1;
-  INSERT INTO t1(x) SELECT x+16 FROM t1;
-  INSERT INTO t1(x) SELECT x+32 FROM t1;
-  INSERT INTO t1(x) SELECT x+64 FROM t1;
-  INSERT INTO t1(x) SELECT x+128 FROM t1;
-  INSERT INTO t1(x) SELECT x+256 FROM t1;
-  INSERT INTO t1(x) SELECT x+512 FROM t1;
-  INSERT INTO t1(x) SELECT x+1024 FROM t1;
-  INSERT INTO t1(x) SELECT x+2048 FROM t1;
-  INSERT INTO t1(x) SELECT x+4096 FROM t1;
-  INSERT INTO t1(x) SELECT x+8192 FROM t1;
-  INSERT INTO t1(x) SELECT x+16384 FROM t1;
-  INSERT INTO t1(x) SELECT x+32768 FROM t1;
-  INSERT INTO t1(x) SELECT x+65536 FROM t1;
-  UPDATE t1 SET y=x/2 WHERE x>1;
   COMMIT;
   CREATE VIRTUAL TABLE cx 
    USING transitive_closure(tablename=t1, idcolumn=x, parentcolumn=y);
 } {}
 
 # The entire table
-do_execsql_test 1.1 {
+do_timed_execsql_test 1.1 {
   SELECT count(*), depth FROM cx WHERE root=1 GROUP BY depth ORDER BY 1;
 } {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/}
+do_timed_execsql_test 1.1-cte {
+  WITH RECURSIVE
+    below(id,depth) AS (
+      VALUES(1,0)
+       UNION ALL
+      SELECT t1.x, below.depth+1
+        FROM t1 JOIN below on t1.y=below.id
+    )
+  SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1;
+} {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/}
 
 # descendents of 32768
 do_execsql_test 1.2 {
@@ -57,9 +52,20 @@ do_execsql_test 1.2 {
 } {32768 0 65536 1 65537 1 131072 2}
 
 # descendents of 16384
-do_execsql_test 1.3 {
+do_timed_execsql_test 1.3 {
   SELECT * FROM cx WHERE root=16384 AND depth<=2 ORDER BY id;
 } {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2}
+do_timed_execsql_test 1.3-cte {
+  WITH RECURSIVE
+    below(id,depth) AS (
+      VALUES(16384,0)
+       UNION ALL
+      SELECT t1.x, below.depth+1
+        FROM t1 JOIN below on t1.y=below.id
+       WHERE below.depth<2
+    )
+  SELECT id, depth FROM below ORDER BY id;
+} {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2}
 
 # children of 16384
 do_execsql_test 1.4 {
index 109fb310a9e27cfe005bcd6acb3f780ef32f8cc1..fefd5e8a8fc631e62084b74cca2a54f4c7da4dd6 100644 (file)
@@ -59,6 +59,7 @@
 #      do_test                TESTNAME SCRIPT EXPECTED
 #      do_execsql_test        TESTNAME SQL EXPECTED
 #      do_catchsql_test       TESTNAME SQL EXPECTED
+#      do_timed_execsql_test  TESTNAME SQL EXPECTED
 #
 # Commands providing a lower level interface to the global test counters:
 #
@@ -717,6 +718,11 @@ proc do_catchsql_test {testname sql result} {
   fix_testname testname
   uplevel do_test [list $testname] [list "catchsql {$sql}"] [list $result]
 }
+proc do_timed_execsql_test {testname sql {result {}}} {
+  fix_testname testname
+  uplevel do_test [list $testname] [list "execsql_timed {$sql}"]\
+                                   [list [list {*}$result]]
+}
 proc do_eqp_test {name sql res} {
   uplevel do_execsql_test $name [list "EXPLAIN QUERY PLAN $sql"] [list $res]
 }
@@ -1013,6 +1019,14 @@ proc execsql {sql {db db}} {
   # puts "SQL = $sql"
   uplevel [list $db eval $sql]
 }
+proc execsql_timed {sql {db db}} {
+  set tm [time {
+    set x [uplevel [list $db eval $sql]]
+  } 1]
+  set tm [lindex $tm 0]
+  puts -nonewline " ([expr {$tm*0.001}]ms) "
+  set x
+}
 
 # Execute SQL and catch exceptions.
 #