[SERVER-37116] Query with sort ascending get response very slow Created: 13/Sep/18 Updated: 27/Oct/23 Resolved: 14/Sep/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 4.0.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Lê Trung Trung | Assignee: | Nick Brewer |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
I have 30_000_000 Documents: {_id:long, owner:string, content:string} I have a query: { "_id": { $gt: NumberLong(22047817660001) }, "ci": "0938186066:0938186061" } + Case 1: do query with sort = descending and limit = 50 => Receiving data in 0.002s + Case 1: do query with sort = ascending and limit = 50 => Receiving data in 9s
|
| Comments |
| Comment by Lê Trung Trung [ 14/Sep/18 ] |
|
I query and sort on my index _id , why query examine on many documnents? |
| Comment by Nick Brewer [ 14/Sep/18 ] |
|
letrungtrung1987 Your ascending query has to examine significantly more documents - when you perform an ascending sort, you are essentially telling the query to look from NumberLong(22047817660001) to infinity, to find documents that meet your equality match. Most of the documents that meet this are the upper end of that range, so a descending query (which starts from infinity) is able to find the documents that match more quickly. Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-user group. -Nick |
| Comment by Lê Trung Trung [ 14/Sep/18 ] |
|
This files contains: + Ascending Explain: https://goo.gl/4J66sx + Descending Explain: https://goo.gl/3jhhtt
And i uploaded this information to your secure portal, please check it |
| Comment by Nick Brewer [ 13/Sep/18 ] |
|
letrungtrung1987 Can you provide explain() output for both the ascending and descending queries? You can upload this information to our secure portal to ensure that it is only available to MongoDB employees. Thanks, |
| Comment by Lê Trung Trung [ 13/Sep/18 ] |
|
+ Case 3: => do query without sort = ascending and limit = 50 => Receiving data in 0.002s |