How can i improve performance insert data in SQLite Database.
The Amount of data is 30000 Records. The Code is:
- (void)insertBranchDB:branchlistArray
{
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
int count = 0;
for (Branch *branch in branchlistArray) {
NSString *insertSQL = [NSString stringWithFormat:
@"insert or replace into Branch (id, lang, lat, lng, province_id, district_id, optional, bus, status, name, address, contact, telephone, remark, province_name, district_name, lastupdate) values (\"%@\", \"%@\", \"%@\", \"%@\",\"%@\", \"%@\", \"%@\", \"%@\",\"%@\", \"%@\", \"%@\", \"%@\",\"%@\", \"%@\", \"%@\", \"%@\", \"%@\")",branch._id,branch.lang,branch.lat,branch.lng,branch.province_id,branch.district_id,branch.optional,branch.bus,branch.status,branch.name,branch.address,branch.contact,branch.telephone,branch.remark,branch.province_name,branch.district_name,branch.lastupdate];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(database, insert_stmt,-1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE) {
NSLog(@"Completed to Add Branch %d",count);
count;
}
else {
NSLog(@"Failed to Add Branch %d",count);
count;
}
}
sqlite3_finalize(statement);
sqlite3_close(database);
}
}