I am trying to insert around 500 records into the sqlite database, it is taking 20 sec, which is way too much! Could anyone please tell how to optimize this.
for (int i = 0 ; i< [[[dic objectForKey:@"response" ]objectForKey:@"requete"]count]; i++) {
[sqlManager executeQuery:[[[dic objectForKey:@"response"]objectForKey:@"requetes"]objectAtIndex:i]];
}
with
-(void)executeQuery:(NSString*)_query
{
sqlite3 *database;
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
if(sqlite3_exec(database, [_query UTF8String],NULL, NULL, NULL) == SQLITE_OK){
//NSLog(@"Query Success");
}
else{
// NSLog(@"Query Failed");
}
sqlite3_close(database);
}
sqlite3_close(database);
}