Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | A few simple test cases for the ORDER BY LIMIT optimization. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | orderby-limit |
Files: | files | file ages | folders |
SHA1: |
08849eab0f6ef29eaf6d2ce9c692de9b |
User & Date: | drh 2016-05-20 00:21:42.961 |
Context
2016-05-20
| ||
13:44 | Set the NULLEQ flag on the sequence counter comparison in the ORDER BY LIMIT optimization, to avoid coverage complaints about not testing the NULL case. (Closed-Leaf check-in: ed1b30dc93 user: drh tags: orderby-limit) | |
00:21 | A few simple test cases for the ORDER BY LIMIT optimization. (check-in: 08849eab0f user: drh tags: orderby-limit) | |
2016-05-19
| ||
22:40 | Appears to work now. Needs test cases, more comments, and code optimization. (check-in: 990fe50c91 user: drh tags: orderby-limit) | |
Changes
Added test/limit2.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | # 2016-05-20 # # 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 regression tests for SQLite library. The # focus of this file is testing the LIMIT in combination with ORDER BY # and in particular, the optimizations in the inner loop that cause an # early exit of the inner loop when the LIMIT is reached and the inner # loop is emitting rows in ORDER BY order. set testdir [file dirname $argv0] source $testdir/tester.tcl do_execsql_test limit2-100 { CREATE TABLE t1(a,b); WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000) INSERT INTO t1(a,b) SELECT 1, (x*17)%1000 + 1000 FROM c; INSERT INTO t1(a,b) VALUES(2,2),(3,1006),(4,4),(5,9999); CREATE INDEX t1ab ON t1(a,b); } set sqlite_search_count 0 do_execsql_test limit2-100.1 { SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b LIMIT 5; } {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} set fast_count $sqlite_search_count set sqlite_search_count 0 do_execsql_test limit2-100.2 { SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b LIMIT 5; } {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} do_test limit2-100.3 { set slow_count $sqlite_search_count expr {$fast_count < 0.02*$slow_count} } {1} do_execsql_test limit2-110 { CREATE TABLE t2(x,y); INSERT INTO t2(x,y) VALUES('a',1),('a',2),('a',3),('a',4); INSERT INTO t2(x,y) VALUES('b',1),('c',2),('d',3),('e',4); CREATE INDEX t2xy ON t2(x,y); } set sqlite_search_count 0 do_execsql_test limit2-110.1 { SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY t1.b LIMIT 5; } {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} set fast_count $sqlite_search_count set sqlite_search_count 0 do_execsql_test limit2-110.2 { SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY +t1.b LIMIT 5; } {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |} set slow_count $sqlite_search_count do_test limit2-110.3 { expr {$fast_count < 0.02*$slow_count} } {1} do_execsql_test limit2-120 { DROP INDEX t1ab; CREATE INDEX t1ab ON t1(a,b DESC); } set sqlite_search_count 0 do_execsql_test limit2-120.1 { SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b DESC LIMIT 5; } {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |} set fast_count $sqlite_search_count set sqlite_search_count 0 do_execsql_test limit2-120.2 { SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b DESC LIMIT 5; } {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |} do_test limit2-120.3 { set slow_count $sqlite_search_count expr {$fast_count < 0.02*$slow_count} } {1} finish_test |