This Query Is Taking Too Long

Discussion in 'iOS Programming' started by oo7ml, Jul 29, 2014.

  1. oo7ml macrumors 6502

    Jan 20, 2010
    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]];
    Thanks in advance for your help.
  2. JohnsonK macrumors regular

    Mar 6, 2014
    It might be an issue between your connection and parse's servers.

    My experience with Parse is that it has always been really fast, *almost* instant. That being said, Parse might not be the best option for an instant messaging app.

    While it does provide a good way to store data, it will not automatically push new messages into your app, you are going to have to query it every few seconds with a timer for instance, adding to the time you are already waiting for the queries to finish. That means your app is not going to be a true *instant* messaging.

    Its free plan also limits you to 30 requests per second. If you plan on expanding your app, you are going to blow this limit pretty fast with the timer querying parse every, say, 5 seconds.

Share This Page