Thanks for the replies. For my purpose it was about avoiding the possibility of 
having to apply a limit to a query that might already have a limit clause.

From: Dominique Devienne<mailto:ddevie...@gmail.com>
Sent: 16 February 2018 12:00
To: SQLite mailing list<mailto:sqlite-users@mailinglists.sqlite.org>
Subject: Re: [sqlite] LIMIT versus sqlite3_step LIMIT times

On Fri, Feb 16, 2018 at 12:33 PM, Cezary H. Noweta <c...@poczta.onet.pl>
wrote:

> On 2018-02-16 11:18, x wrote:
>
>> If a query is sorted on an index is there any advantage to including
>> LIMIT in the stmt as opposed to omitting it and stepping through the result
>> set LIMIT times?
>>
>
> No -- LIMIT appends an additional opcode to check the number of rows and
> introduces an effort related to an additional parsing. In general, LIMIT
> can reduce a cost of a full external sorting, however this does not apply
> to your query.
>

While you're technically right, I think of SQL as a declarative language,
and as such I'd say giving this information to SQLite is a best practice
IMHO.
Unlikely in this case, but perhaps one day SQLite might be able to optimize
"something" based on it. And in general, not all queries are that simple.
Giving the query planner all possible information should be recommended. My
$0.02. --DD
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to