Hello,

Let say we create two tables:

create table a(num integer primary key);create unique index a_uq on a(num);
create table b(num integer primary key);create unique index b_uq on b(num);

Table a is populated with 1 million records and table b with 1000 records. We 
run analyze and look at sqlite_stat1 table:

d|d_uq|1000 1
a|a_uq|1000000 1

Now I run two selects with different orders of joins:

select * from a join b using(num);
select * from b join a using(num);

Corresponding timings are

CPU Time: user 0.000000 sys 0.000000
CPU Time: user 0.343750 sys 0.000000

This shows that query analyzer is broken - it does not reorder simple inner 
join based on collected statistics. 

It worked OK in 3.6 and first release of 3.7 (although required _uq indexes in 
addition to primary key since no statistics on primaries were used).

Please advice.


Peter.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to