"Csaba" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I have a table and I run a query against it with a LIMIT 1000 > clause, then presumably once 1000 rows matching the > query have been found, SQLite can return.
I'm not sure what you mean by "can return". You get one row for every call to sqlite3_step. With the LIMIT clause, you'll just get SQLITE_DONE code on 1000'th call to sqlite3_step. Or, you can simply call sqlite3_reset or sqlite3_finalize after retrieving 1000 rows, and not bother with LIMIT clause. There's no difference. > Does this change if I have an ORDER BY clause that does > not match any index? No (though it would take longer to get the first row, as SQLite will have to retrieve and sort all the records first). > If it does match an index, will SQLite > be clever enough to use that index? Yes. > The intention of the question is that I will be receiving queries > from users, but if the query returns too many records, then > I'd rather abort it as soon as possible. So the real intent of > the question is about how SQLite aborts with respect to > the LIMIT and ORDER BY clause Why not use sqlite3_progress_handler and limit by running time, rather than the number of rows? It's easy to construct a SQL statement that takes a very long time to return zero rows. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users