Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios中firebase中大型数据库的读取数据速度较慢_Ios_Objective C_Firebase_Firebase Realtime Database - Fatal编程技术网

ios中firebase中大型数据库的读取数据速度较慢

ios中firebase中大型数据库的读取数据速度较慢,ios,objective-c,firebase,firebase-realtime-database,Ios,Objective C,Firebase,Firebase Realtime Database,我正在使用firebase进行聊天应用。我从那里存储有关用户的所有信息。通常,如果Firebase数据库没有大数据,它会给出快速响应。但一旦数据库中的数据增加,它就会变得太慢。同样的数据库在我的android应用程序上运行得非常好。请帮我解决这个问题 我使用以下方法从firebase获取数据 -(void) get_grouplist_refresh_single{ @try{ appDel.totalUnreadMsg = 0; [[FIRDataba

我正在使用firebase进行聊天应用。我从那里存储有关用户的所有信息。通常,如果Firebase数据库没有大数据,它会给出快速响应。但一旦数据库中的数据增加,它就会变得太慢。同样的数据库在我的android应用程序上运行得非常好。请帮我解决这个问题

我使用以下方法从firebase获取数据

-(void) get_grouplist_refresh_single{

    @try{
        appDel.totalUnreadMsg = 0;
        [[FIRDatabase database] goOnline];
        FIRDatabaseReference *rootRef= [[FIRDatabase database] referenceWithPath:[NSString stringWithFormat:@"/users/%@/activeGroups",appDel.UserId]];
        [rootRef  observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
            //NSLog(@"group: %@", snapshot.value);
            if ([snapshot exists]) {

                NSDictionary *postDict = snapshot.value;
                NSArray *key_dictionary=[postDict allKeys];
                if (key_dictionary.count > 0) {
                    for (int i=0; i < key_dictionary.count; i++) {
                        [self set_listner_group :[key_dictionary objectAtIndex:i]];
                        [self load_all_active_groupmsg :[key_dictionary objectAtIndex:i]];
                        if(key_dictionary.count - 1 == i){

                        }

                    }
                }else{

                }
            }else{
                [[FIRDatabase database] goOnline];
            }

        }];
    } @catch (NSException *exception) {
        NSLog(@"NSException %@",exception);
    } @finally {

    }
     }

-(void) set_listner_group :(NSString*) strGroupId{

    @try{
        FIRDatabaseReference *rootRef= [[FIRDatabase database] referenceWithPath:[NSString stringWithFormat:@"/groups/%@",strGroupId]];
        [rootRef  observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
            if ([snapshot exists]) {
                //Do somthing base on requirements
            }

        }];
    } @catch (NSException *exception) {
        NSLog(@"NSException %@",exception);
    } @finally {

    }
}
-(void) load_all_active_groupmsg :(NSString*)strgroupID{

    FIRDatabaseHandle handlerLoadAllMsg = 0;
    FIRDatabaseReference *rootRef= [[FIRDatabase database] referenceWithPath:[NSString stringWithFormat:@"/group_msgs/%@",strgroupID]];
    [rootRef keepSynced:YES];
    handlerLoadAllMsg = [rootRef observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot)
                         {
                             if (snapshot.exists)
                             {
                                 [rootRef removeObserverWithHandle:handlerLoadAllMsg];
                             }
                         }]; 
}
-(无效)获取组列表\u刷新\u单个{
@试一试{
appDel.totalUnreadMsg=0;
[[FIRDatabase database]goOnline];
FIRDatabaseReference*rootRef=[[FIRDatabase database]referenceWithPath:[NSString stringWithFormat:@”/users/%@/activeGroups],appDel.UserId]];
[rootRef observeSingleEventOfType:FIRDataEventTypeValue with Block:^(FIRDataSnapshot*\u非空快照){
//NSLog(@“组:%@”,snapshot.value);
如果([快照存在]){
NSDictionary*postDict=snapshot.value;
NSArray*key_dictionary=[postDict allkey];
如果(key_dictionary.count>0){
for(int i=0;i
应用程序中是否有perf mon?如果没有,您应该开始确定响应问题。。另一个问题是数据节点的结构如何。。。节点内的较大数据始终是网络速度缓慢的问题否,我的应用程序中没有perf Mon。你能告诉我怎么去哪里买吗。我的节点结构没有大多少。同样的结构在android上也能完美地工作。感谢你给我这个链接,也感谢你给我这个解决方案。如果我使用这个解决方案,我在这里可以得到什么好处。你能给我解释一下吗?阅读上面链接中的介绍部分,了解perf-mon是如何使用的。。