Re: [sqlite] Is there ever a perf advantage to LIMIT outside of a subquery?

2018-05-11 Thread Richard Hipp
On 5/11/18, Deon Brewis wrote: > e.g. If you do: > > SELECT c1 from t1 ORDER BY c2 LIMIT 5; > > vs. just running the query without the "LIMIT" clause and taking the top 5 > rows programmatically? Yes, if there is an ORDER BY that cannot be satisfied by an index and the total

Re: [sqlite] Is there ever a perf advantage to LIMIT outside of a subquery?

2018-05-11 Thread Simon Slavin
On 11 May 2018, at 9:50pm, Deon Brewis wrote: > e.g. If you do: > > SELECT c1 from t1 ORDER BY c2 LIMIT 5; > > vs. just running the query without the "LIMIT" clause and taking the top 5 > rows programmatically? The LIMIT clause just tells sqlite3_step() to return SQLITE_DONE

[sqlite] Is there ever a perf advantage to LIMIT outside of a subquery?

2018-05-11 Thread Deon Brewis
e.g. If you do: SELECT c1 from t1 ORDER BY c2 LIMIT 5; vs. just running the query without the "LIMIT" clause and taking the top 5 rows programmatically? Obviously in the case of a subquery this makes a difference: select count(*) from (select * from t1 limit 5); But would it ever in a