Link to home
Start Free TrialLog in
Avatar of oo7ml
oo7ml

asked on

Why Is This Taking So Long To Load

Hi, i am building my first app which is a simple instant messaging app that allows users to send an instant update to their partner, or request an update from their partner (one to one)

The Messages area has 3 types of messages listed in chrono order (distinguished using 3 different colors):

- received (messages that you receive from your partner)
- sent (messages that you sent to your partner)
- request (update requests that your partner has sent to you)

When a user clicks into the messages screen, the query below is executed to call all of your messages. I only have a 6 test users now with about 150 messages in the database and sometimes it takes 7-8 seconds for this screen to load all of the messages.

Can anyone suggest how i could improve this area / query:

// received
 PFQuery *receive = [PFQuery queryWithClassName:PARSE_TABLE_CALL];
 [receive whereKey:PARSE_CALL_STATUS equalTo:@"Sent"];
 [receive whereKey:PARSE_CALL_TO equalTo:usersPhone];
 
 // sent
 PFQuery *sent = [PFQuery queryWithClassName:PARSE_TABLE_CALL];
 [sent whereKey:PARSE_CALL_STATUS equalTo:@"Sent"];
 [sent whereKey:PARSE_CALL_FROM equalTo:usersPhone];
 
 // requests
 PFQuery *receiveReq = [PFQuery queryWithClassName:PARSE_TABLE_CALL];
 [receiveReq whereKey:PARSE_CALL_TO equalTo:usersPhone];
 [receiveReq whereKey:PARSE_CALL_STATUS equalTo:@"Request"];
  
 PFQuery *query = [PFQuery orQueryWithSubqueries:@[receive, sent, receiveReq]];

Open in new window


Thanks in advance for your help.
ASKER CERTIFIED SOLUTION
Avatar of KRUNAL TAILOR
KRUNAL TAILOR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oo7ml
oo7ml

ASKER

Hi, thanks for your reply, and apologies for my late reply.

What would be a good way to trigger the messages to download, without clicking into the Inbox