This Query Is Taking Too Long

Joined
Oct 18, 2011
Messages
160
Reaction score
0
Points
16
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:

Code:
// 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]];

Thanks in advance for your help.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top