Slow query [iOS]

admin = false AND gender = 2 AND Discovery = true AND objectId != '2D2885AF-70EB-2B13-FFD2-78B8691A6000' AND distance( 49.2635385, -123.1385709, location.latitude, location.longitude ) < mi(18.0)

Application Id is : 5F3BA2F5-9BAA-E70F-FF7E-CDA02D820600
Performing this where query on the DB takes around 2-4 second on the Rest Console and 4-6 second in the iOS App. I tried even changing autoload for DpLarge and DpSmall file columns to false/OFF but it didn’t made any noticable improvements.
Tinder probably would have a 1-2 second time.
Please advice.

What if you turn off the autoload for “location”? Does it make it run faster in the app?

That brings down the app query time to 3 second and in Rest console to 1-1.3 second.

The “distance” function is rather expensive. I think this is the best you can get with our current implementation.

It kinda reached 4-5 sec again inside app. Can you try your side to see if the result are in a constant range ?

This is my query code in iOS

 let dataQuery = BackendlessDataQuery();
        let queryOptions = QueryOptions()

        var dataClause = "admin = false "
             dataClause = dataClause + "AND gender = \(interested) "
                        dataClause = dataClause + "AND nationality = '\(countrySpectificUser)'"

        //filter who enabled that they can discovered by anyone
        dataClause = dataClause + "AND Discovery = \(true) "

        dataClause = dataClause + "AND objectId != '" + currentLoggedInUser.objectId + "' ";

               dataClause =  dataClause + "AND distance( \(usergeo.latitude), \(usergeo.longitude), location.latitude, location.longitude ) < mi(\(limitlocation))"
        dataQuery.queryOptions  = queryOptions;

        dataQuery.whereClause = dataClause
  let contactStorage = Backendless.sharedInstance().persistenceService.of( BackendlessUser );

        contactStorage.find(query, response: { (collection) -> Void in


I tried using REST Console and am getting the following results:</img>

A simple query to get all Backendless User on the rest console takes around 700 ms while the same takes 2 second inside the app ? Just tested.

This will effect the feasibility of the app since fast load time are required for this query.

Please advise

Hi Kim,

I just tried to GET all Users from the REST console in your app and got them in 350-450ms.

Could you please provide the full sample code with which you test the performance of the SDK and also the screenshots of how you test the retrieval from the REST console?

Rest console screenshot

The code i used in iOS (just integrated in the DocSamples swift project)

Backendless.sharedInstance().initApp("5F3BA2F5-9BAA-E70F-FF7E-CDA02D820600", secret: "", version: "v1")

        let dataQuery = BackendlessDataQuery();
        let contactStorage = Backendless.sharedInstance().persistenceService.of( BackendlessUser );
        contactStorage.find(dataQuery, response: { (collection) -> Void in
            }, error: { (fault) -> Void in

Any update ?

Hi KIm,

We cannot reproduce this issue.
We have created a sample project (see in attachment), which uses your code with your app:</img>
Here is a result log:</img>
So, it works for us. Try this project and let us about a result.

Slava (19.94MB)