我的 sqlite 表中有 10000 条记录。加载到数组中需要 3 多分钟。我怎样才能加快这个过程。有什么办法可以将时间减少到至少一半?
我的代码:
NSString *qry=[NSString stringWithFormat:@"select * from employees"];
    const char *sql=(char *)[qry UTF8String];
    if (sqlite3_prepare_v2(database, sql, -1, &selectstmt,NULL) != SQLITE_OK) {
        NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
    }
    if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
        Vertex *objVertex = [[Vertex alloc] init];
        int counterIndex=0;
         while(sqlite3_step(selectstmt) == SQLITE_ROW){
            objVertex.vid=sqlite3_column_int(selectstmt, 0);
            objVertex.lat=sqlite3_column_double(selectstmt, 1);
            objVertex.lon=sqlite3_column_double(selectstmt, 2);
            objVertex.alt=sqlite3_column_double(selectstmt, 3);
            objVertex.assoc_type=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 4)];
            objVertex.assoc_id=sqlite3_column_int(selectstmt, 5);
            objVertex.link=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 6)];
            objVertex.bf=sqlite3_column_int(selectstmt, 7);
            
             [appdel.dicVertexEntry setObject:[NSString stringWithFormat:@"%d",counterIndex] forKey:[NSString stringWithFormat:@"%d",objVertex.vid]];
             // do pass vertex to Algo
             counterIndex++;
        
        }
        [[NSUserDefaults standardUserDefaults]setObject:appdel.dicVertexEntry forKey:@"VertexData"];
        [[NSUserDefaults standardUserDefaults]synchronize];
    }
提前致谢。