On 11 Mar 2019, at 7:30pm, Tim Streater <t...@clothears.org.uk> wrote:

> What is the maximum size in bytes that a result set may be? And what happens 
> if that size were to be exceeded?

[The following is simplified for clarity.  I discuss only worst cases and 
ignore caching.]

SQLite does not prepare an entire result set at once.  Instead, it returns one 
row each time you call sqlite3_step().  It's up to your own program to process 
each row as it is returned.  Since SQLite does not hold more than one row in 
memory at once, theoretically there's no limit on how many rows it can return 
for a single query.

However, some queries may require SQLite to prepare a temporary index.  For 
example, a SELECT with an ORDER BY where there's no useful index.  A large 
temporary index would be saved on disk until it is no longer needed.  In these 
situations, SQLite is limited by the amount of disk space made available to the 
application calling SQLite.

Similarly, you may be calling sqlite3_exec() instead of sqlite3_step().  Or you 
may be calling SQLite through a library which does hold an entire result set in 
memory at one time.  In that case, the maximum size of a result set is limited 
by the amount of memory the application can use, and management of that memory 
takes place outside of SQLite.

Attempts to exceed any of the above limits would lead to result codes such as 
SQLITE_NOMEM or SQLITE_IOERR.  A list of result codes can be found here:

<https://sqlite.org/c3ref/c_abort.html>

For details on the limits to SQLite's other things such as the most rows a 
table can hold, please see this document:

<https://sqlite.org/limits.html>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to