On Thu, Nov 17, 2016 at 04:48:20PM +0200, Paul wrote: > Replacing JOIN does not help either: > > sqlite> EXPLAIN QUERY PLAN SELECT foo.id FROM bar JOIN foo ON bar.foo = > foo.id ORDER BY id DESC LIMIT 0, 40; > selectid order from detail > > ---------- ---------- ---------- > ---------------------------------------------------------------------------------------------------- > 0 0 1 SCAN TABLE foo > > 0 1 0 SEARCH TABLE bar USING INTEGER PRIMARY > KEY (rowid=?) > > My guess is it's because there are no sqlite_stat* tables and SQLite > doesn't know that bar scan is more efficient. That's why there was a > LEFT JOIN in the first place, but as it seems, it wasn't that good > idea.
If you want the ORDER BY to not sort (either as results are generated or after, but either way before the application sees a single result) then you kinda need to scan foo first. Is there any other way? I don't think so, but correct me! Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users