Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:32:38+00:00 2026-06-13T16:32:38+00:00

I have a collection, the data look like this: { _id : ObjectId(4e627655677c27cf24000000), gps

  • 0

I have a collection, the data look like this:

{
    "_id" : ObjectId("4e627655677c27cf24000000"),
    "gps" : {
        "lng" : 116.343079,
        "lat" : 40.034283
    },
    "lat" : 1351672296
}

And I build a compound index:

{
    "v" : 1,
    "key" : {
        "gps" : "2d",
        "lat" : 1
    },
    "ns" : "test.user",
    "name" : "gps__lat_1"
}

A pure $near query like below can be very fast ( < 20ms ):

>db.user.find({"gps":{"$near":{"lng":116.343079,"lat":40.034283}}}).explain()
{
    "cursor" : "GeoSearchCursor",
    "nscanned" : 100,
    "nscannedObjects" : 100,
    "n" : 100,
    "millis" : 23,
    "nYields" : 0,
    "nChunkSkips" : 0,
    "isMultiKey" : false,
    "indexOnly" : false,
    "indexBounds" : {

    }
}

But the query with “lat” criteria is very slow ( 900ms+ ):

>db.user.find({"gps":{"$near":{"lng":116.343079,"lat":40.034283}},"lat":{"$gt":1351413167}}).explain()
{
    "cursor" : "GeoSearchCursor",
    "nscanned" : 3,
    "nscannedObjects" : 3,
    "n" : 3,
    "millis" : 665,
    "nYields" : 0,
    "nChunkSkips" : 0,
    "isMultiKey" : false,
    "indexOnly" : false,
    "indexBounds" : {

    }
}    

Can anybody explain this? Great thx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:32:39+00:00Added an answer on June 13, 2026 at 4:32 pm

    I updated my Mongodb up to 2.2.0, the problem disappeared.

    127.0.0.1/test> db.user.find({gps:{$near:[116,40]},lat:{$gt:1351722342}}).explain()
    {
        "cursor" : "BasicCursor",
        "isMultiKey" : false,
        "n" : 0,
        "nscannedObjects" : 0,
        "nscanned" : 0,
        "nscannedObjectsAllPlans" : 0,
        "nscannedAllPlans" : 0,
        "scanAndOrder" : false,
        "indexOnly" : false,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 0,
        "indexBounds" : {
    
        },
        "server" : "zhangshenjiamatoMacBook-Air.local:27017"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a collection of users like this:- { _id : 1234, Name
I have a collection of GPS data points with timestamps that I'm using to
I have a collection of user models that starts with basic data: [ {'_id':
I have 2 related database tables which in simplified form look like this Product(
I have had a look at this Flatten LINQ collection object with nested object
I have a Stored Procedure that look like this BEGIN insert into `TheSomaProject`.`Projects` (
We have a data collection system that collects measurements from environmental sensors that measure
I have a MongoDB collection with data that was not saved through my Derby
I have constructed a collection of data series items. Each data series has multiple
I have a small data collection app which has a single button to start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.