Hi! Given this schema:

create table q (id integer primary key, idLevel integer);
create table level (id integer primary key);

insert into q values(1, 1);
insert into q values(2, 1);
insert into q values(3, 1);
insert into level values(1);

When running this query:
select p.* FROM
q as p
inner join level pn ON (p.idLevel = pn.id)
where p.idLevel = 1
ORDER BY  random()  LIMIT 10

The results are not on random order on SQLite 3.8.0.2
Verifying with EXPLAIN QUERY PLAN , it can be seen that no ORDER BY step is
included.

if one of the following is changed:
LEFT join level instead of inner or the where clause condition is changed to
p.idLevel >=1 and p.idLevel <= 1, the Order by step is included in the
query, and the result order is random as expected.

Anything I'm missing ?




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Possible-issue-in-optimizer-strips-away-order-by-tp74134.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to