Android: how to find SQLITE_MAX_COMPOUND_SELECT

Is there any way to get SQLITE_MAX_COMPOUND_SELECT value of SQLITE_MAX_COMPOUND_SELECT database on Android? In the sqlite3 C API, it is sqlite3_limit(db, SQLITE_LIMIT_COMPOUND_SELECT, -1) , but I do not see this interface in the Android SQLite API .

The reason for this is that I insert thousands of rows, and the release of the INSERT batch statement is faster than many single-line inserts, even when it is enclosed in a transaction. But the maximum number of rows that can be inserted for each statement is limited by SQLITE_MAX_COMPOUND_SELECT , which requires splitting it into several batches. And, for obvious reasons, I would rather not set the default limit to 500 hard.

+3
source share
1 answer

The SQLITE_LIMIT_COMPOUND_SELECT limit SQLITE_LIMIT_COMPOUND_SELECT not a means of preventing memory overflow (at least for Android systems), but simply a health check. Therefore, it is highly unlikely that the provider will reduce it by default, so 500 should be safe.

In addition, as the number of inserted records in one command becomes larger, incremental acceleration will decrease; for example, accelerating the transition from 5 to 50 records will be more than accelerating the transition from 50 to 500. Therefore, just using 50 should not hurt much.


Another way to speed up repeated executions is to use prepared statements with SQLiteDatabase.compileStatement .

+1
source

Source: https://habr.com/ru/post/973693/


All Articles