Parse GeoPoint request is slow and timeout using javascript sdk in node.js

I have the following parsing request that expires when the number of records is large.

var query = new Parse.Query("UserLocation");
query.withinMiles("geo", geo, MAX_LOCATION_RADIUS);
query.ascending("createdAt");

if (createdAt !== undefined) {
    query.greaterThan("createdAt", createdAt);
}
query.limit(1000);

      

it works fine if the UserLocation table is small. But the query time is from time to time when the table has ~ 100k records:

[2015-07-15 21:03:30.879] [ERROR] [default] - Error while querying for locations: [latitude=39.959064, longitude=-75.15846]: {"code":124,"message":"operation was slow and timed out"}

      

The UserLocation table has a latitude, longitude, and radius pair. Given a geographic point (latitude, longitude), I am trying to find a list of UserLocations whose circle (lat, long) + radius covers the given geo point. I can't seem to use a value from another column in the table to query the distance (something like query.withinMiles("geo", inputGeo, "radius")

where "geo" and "radius" are the column names for the GeoPoint and radius). It also has the limitation that the "limit" query combined with "skip" can return a maximum of 10,000 records (1000 records at a time and skip 10 times). So I had to do a near full scan of the table using "createdAt" as the filter criterion and continuing the query until the query returned no more results.

Is there anyway I can improve the algorithm so that it doesn't fall out on a large dataset?

+3


source to share





All Articles