[sqlite] Problem: Index not used with ORDER BY on view

2012-10-24 Thread Scholz Maik (CM-AI/PJ-CF42)
Hi, I have some strange behavior with the query optimizer. SQLite version 3.7.7.1 2011-06-28 17:39:05 sqlite create table t1 (a,b); sqlite insert into t1 (a,b) values (1,2); sqlite insert into t1 (a,b) values (3,4); sqlite select * from t1; 1|2 3|4 sqlite create index i1 on t1(a); sqlite

Re: [sqlite] Problem: Index not used with ORDER BY on view

2012-10-24 Thread Simon Slavin
On 24 Oct 2012, at 9:59am, Scholz Maik (CM-AI/PJ-CF42) maik.sch...@de.bosch.com wrote: sqlite explain query plan select a,b,f1 from v1 where a=3 order by (f1); 0|0|0|SEARCH TABLE t1 USING INDEX i1 (a=?) (~10 rows) 0|0|0|USE TEMP B-TREE FOR ORDER BY = Why is index i1 not used? It

Re: [sqlite] Problem: Index not used with ORDER BY on view

2012-10-24 Thread Richard Hipp
On Wed, Oct 24, 2012 at 4:59 AM, Scholz Maik (CM-AI/PJ-CF42) maik.sch...@de.bosch.com wrote: Hi, I have some strange behavior with the query optimizer. SQLite version 3.7.7.1 2011-06-28 17:39:05 sqlite create table t1 (a,b); sqlite insert into t1 (a,b) values (1,2); sqlite insert into t1

Re: [sqlite] Problem: Index not used with ORDER BY on view

2012-10-24 Thread Scholz Maik (CM-AI/PJ-CF42)
Hi, My expectation was, that the actual used ORDER term is something like merge from outer to inner orders. But, this is wrong. Perhaps we could add a new optimization: IF: (1) both inner and outer queries have an ORDER BY clause, and (2) the inner query omits both LIMIT and

Re: [sqlite] Problem: Index not used with ORDER BY on view

2012-10-24 Thread Clemens Ladisch
(quoting fixed) Scholz Maik (CM-AI/PJ-CF42) wrote: Richard Hipp wrote: Perhaps we could add a new optimization: IF: (1) both inner and outer queries have an ORDER BY clause, and (2) the inner query omits both LIMIT and OFFSET THEN: drop the ORDER BY from