小编vin*_*ent的帖子

在iPhone上的SQLite DB中插入1000行16秒?

我试图在我的sqlite数据库中插入1000行,但是花了超过16秒..我的代码中有什么问题我没看到?

 NSLog(@"--start--");

 if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
  static sqlite3_stmt *compiledStatement;

  for(int k = 0; k < 1000; k++)
   sqlite3_exec(database, [[NSString stringWithFormat:@"insert into myTable (id, name) values ('%i', 'a')", k] UTF8String], NULL, NULL, NULL);

  sqlite3_finalize(compiledStatement);

  sqlite3_close(database);
 }

 NSLog(@"--stop--");


start : 2010-11-27 11:21:11.704 
stop  : 2010-11-27 11:21:27.908
Run Code Online (Sandbox Code Playgroud)

谢谢 !

sqlite iphone

6
推荐指数
3
解决办法
1887
查看次数

标签 统计

iphone ×1

sqlite ×1