I have an app using SQLite3. It's running pretty well, but I would like suggestions on speeding up SQLite (write) access. Most of the database operations are writing triples (int, int, double) of numbers, about 20-50 triples per second. There is an occasional read, but is about as rare as hen's teeth (mostly occurs on loading only).
Does anyone have suggestions on optimizing (or at lease de-pessimizing) the code? Any SQLite3 shortcuts I missed? (Using CoreData is right out because of other stuff in the program.)
I prepare the statement st1 during initialization. It is prepared from
const char *sql = "insert into historic values (?, ?, ?)";
if (sqlite3_prepare_v2(database, sql, -1, &st1, NULL) == SQLITE_OK) ....
This preparation is one-time. The snippet I am using for saving is below (i've removed error checking here for clarity).
-(BOOL) saveHvalue:(int) fid time:(int) t value:(double) v type:(int) ftype
{
{
sqlite3_bind_int(st1, 1, fid);
sqlite3_bind_int(st1, 2, t);
sqlite3_bind_int(st1, 3, ftype);
sqlite3_step(st1);
sqlite3_reset(st1);
sqlite3_clear_bindings(st1);
}
return YES;
}