I have an android sqlite database that is currently very slow to execute.
per the advice of Improve INSERT-per-second performance of SQLite? I have changed from doing update if failed insert routine to just use replace (which is the same as REPLACE INTO also known as INSERT OR REPLACE)
I now want to change from doing one replace at a time to doing hundreds at a time
static ArrayList<ContentValues> cvs= new ArrayList<ContentSystem>();
_dh.BeginTransaction(Table);
for(int i = 0; i < cvs.size(); ++i)
{
replace(ma, cvs.get(i), dh, Table, Key);
}
_dh.EndTransaction(Table);
into using the bulk system
SQLiteStatement stmt = _dh.db.compileStatement("Replace into tablename(..) value (?,?)");
_dh.BeginTransaction(Table);
for(int i = 0; i < cvs.size(); ++i)
{
stmt.bindString(cvs.get(i));
}
stmt.execute();
_dh.EndTransaction(Table);
But I don't understand how the compile statement would look nor do I understand what I would put in the bind string function - i have the data stored in a contentvalue
Also from this http://developer.android.com/reference/android/database/sqlite/SQLiteStatement.html#execute()
Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example CREATE / DROP table, view, trigger, index etc.
It appears the execute call will not work with replace?? Because it is doing insert/update is this correct?
Here is how my database is set up, and how I am using the replace call http://sqlfiddle.com/#!7/b8af8/1