1. Optimized insertion speed
A. Do not bind empty columns
- In my program, at least 50% of the columns are empty values. When a null value column is encountered, the Ih.bind () method is not called to bind it, and as far as my program is concerned, when the column value is null or the empty string is,
- With nearly 30% performance improvements
B. Temporarily turn off the Sqlitedatabase sync lock check function
- I load the database in the Sqliteopenhelper.oncreate method, during which, if only one thread accesses Databaser, then SQLite does not need synchronous access check
- Therefore, call sqlitedatabase.setlockingenabled (false) to temporarily close the lock check. This measure can be boosted by a 35% rate.
C. sqlitestatement: BULK INSERT data.
String sql = "INSERT into table name (corresponding column) VALUES (?)" = db.compilestatement (sql);d b.begintransaction (); for (DataSet) { // loop The data to be inserted }db.settransactionsuccessful ();d b.endtransaction (); Db.close ();
Android SQLite app optimization (data collation)