OLD | NEW |
1 # 2014-06-06 | 1 # 2014-06-06 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 px | 633 px |
634 WHERE | 634 WHERE |
635 cx.code = '2990' | 635 cx.code = '2990' |
636 AND cx.type=2 | 636 AND cx.type=2 |
637 AND px.cx_id = cx.cx_id | 637 AND px.cx_id = cx.cx_id |
638 AND px.px_tid = 0 | 638 AND px.px_tid = 0 |
639 AND px.le_id = le.le_id; | 639 AND px.le_id = le.le_id; |
640 } {/.*SCAN TABLE cx.*SEARCH TABLE px.*SEARCH TABLE le.*/} | 640 } {/.*SCAN TABLE cx.*SEARCH TABLE px.*SEARCH TABLE le.*/} |
641 | 641 |
642 | 642 |
| 643 # The following test is derived from a performance problem reported from |
| 644 # the field. Notice the multiple indexes with the same initial tables, |
| 645 # and the unusual WHERE clause terms. |
| 646 # |
| 647 do_test 5.1 { |
| 648 set res [db eval { |
| 649 DROP TABLE IF EXISTS t1; |
| 650 CREATE TABLE t1(a,b,c,d,e,f,g,h); |
| 651 CREATE INDEX t1abc ON t1(a,b,c); |
| 652 CREATE INDEX t1abe ON t1(a,b,e); |
| 653 CREATE INDEX t1abf ON t1(a,b,f); |
| 654 ANALYZE; |
| 655 DROP TABLE IF EXISTS sqlite_stat4; |
| 656 DROP TABLE IF EXISTS sqlite_stat3; |
| 657 DELETE FROM sqlite_stat1; |
| 658 INSERT INTO sqlite_stat1(tbl,idx,stat) |
| 659 VALUES('t1','t1abc','2000000 8000 1600 800'), |
| 660 ('t1','t1abe','2000000 8000 1600 150'), |
| 661 ('t1','t1abf','2000000 8000 1600 150'); |
| 662 ANALYZE sqlite_master; |
| 663 |
| 664 EXPLAIN QUERY PLAN |
| 665 SELECT * FROM t1 |
| 666 WHERE (a=1 OR a=2) |
| 667 AND (b=3 OR b=4) |
| 668 AND (d>=5 AND d<=5) |
| 669 AND ((e>=7 AND e<=7) OR (f>=8 AND f<=8)) |
| 670 AND g>0; |
| 671 }] |
| 672 } {~/ANY/} |
| 673 do_test 5.2 {set res} {/USING INDEX t1abe/} |
| 674 do_test 5.3 {set res} {/USING INDEX t1abf/} |
| 675 |
| 676 |
| 677 |
643 finish_test | 678 finish_test |
OLD | NEW |