[SERVER-8256] $within query with sort very slow Created: 21/Jan/13  Updated: 08/Mar/13  Resolved: 08/Mar/13

Status: Closed
Project: Core Server
Component/s: Geo, Querying
Affects Version/s: 2.2.1
Fix Version/s: None

Type: Question Priority: Blocker - P1
Reporter: Jari Rangell Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 64bit in Amazon


Participants:

 Description   

We're using mongo vie spring data and everything else seems to working aok except one geo-query. We're trying to run a bounding box query and sort it so that we only get 50 newest records. For some reason, if we don't specify $sort, all of the coordinates will be in a same very small area. I assume that Query query = new Query(where("loc").within(searchbox)) is sorting the results by distance? Then if we specify the sort-object like query.with(new Sort(Sort.Direction.ASC, "another")) the query will be slowest of the slow. We've created a combound index for that query.

Could someone please help?



 Comments   
Comment by hari.khalsa@10gen.com [ 31/Jan/13 ]

If you're querying for 50 records within a certain box, there is no sorting. I'm not sure what it would sort on Anyway, it would only have to look at 50 items that are within that box to satisfy the query. So it's probably looking at some small region within the box, finding 50 items, and returning them.

If you're querying for 50 records that are in a certain box and sorted by some criteria, the search has to look at every record in that box, then choose the first 50 entries according to the sort criteria. So, depending on how many items are in the box/collection, and the size of the box, and the sort criteria, it could be very slow...

Comment by Jari Rangell [ 22/Jan/13 ]

Thank you Ian, I'll be heading to google groups then and start waiting for someone's timeslot for me.

Comment by Ian Whalen (Inactive) [ 22/Jan/13 ]

Jari, someone will work with you as time allows, but in the meantime you should open a topic on the MongoDB user forums - http://groups.google.com/group/mongodb-user. JIRA is intended as a repository for bug reports and feature requests, while the forums are your best source for answering questions and getting help from the MongoDB team and community.

Comment by Jari Rangell [ 22/Jan/13 ]

How should we proceed? I take that "debugging with submitter" means that Hari Khalsa will be my support.
/Jari

Generated at Thu Feb 08 03:16:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.