2

I am using loopbackjs Geopoint functionality to query based on geolocation.

This is my query:

var loopback = require('loopback');
var here = new loopback.GeoPoint({
    lat: lat,
    lng: lng
});
Asset.find({
    where: {
        Location: {
            near: here,
            maxDistance: 3,
            unit: 'kilometers'
        }
    },
    limit: 10,
    order: 'id DESC'
}, function(err, data) {
    if (err) {
        return error;
    }
    return data
});

Collection schema :

{
    "Location": {
        "lat": 19.230755,
        "lng": 72.838024
    },
    "key": "value",
    //....,
    "id": "5829a3eb95dbcc63da37f48f"
}

This collection has almost 150,000 records. When I use near query, the CPU usage exeeds 100% and after 4-5 consecutive API calls to get the same data, server stops responding.Tried indexing the data but no use, still the same issue persists. Please help.

Vatsy
  • 41
  • 5
  • What's "1,50,000"? It's either 1,500,000 or 150,000. :) – Tomalak Dec 12 '16 at 17:53
  • 1
    What database are you using? In many cases, LoopBack is not able to pass the geo query directly to the database and has to perform the query in memory. If you have 150k records then LoopBack has to load all 150k records to memory and then process it. – Miroslav Bajtoš Dec 14 '16 at 11:44
  • @MiroslavBajtoš Thanks for your Input. Similar was the case why the server was hanging up. I decided to change the Infra and move to SOLR which did wonders for me with less than a second response time. – Vatsy Jan 05 '17 at 10:51
  • Actually I'm doing the same query on a collection of 100,000 records in and takes about 8 sec (on a mongoDB database). Is it the exepected behavior? I suspect it is not. – F3L1X79 Jul 18 '18 at 08:15

0 Answers0