[SERVER-486] Two indexes same field, one ascending, one descending, cause no index to be used Created: 14/Dec/09  Updated: 15/Jan/10  Resolved: 14/Dec/09

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 1.1.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Doug Green Assignee: Eliot Horowitz (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

unix


Participants:

 Description   

I had a collection that had two indexes, one ascending, and one descending

mongo> db.url.getIndexes()
{
"_id" : ObjectId("4b1651417fc9cc6b089203f6"),
"ns" : "scan_stats.url",
"key" :

{ "hours.velocity" : 1 }

,
"name" : "hours_velocity_1",
"unique" : false
},
{
"ns" : "scan_stats.url",
"key" :

{ "hours.velocity" : -1 }

,
"name" : "hours.velocity_-1"
}

This query was taking 6 seconds:

Tue Dec 15 01:37:14 query scan_stats.url ntoreturn:1 reslen:224 nscanned:9236896 { hours.velocity:

{ $gt: 0.0 }

} nreturned:1 6934

I removed the unnecessary index (the ascending one), and then the query became instantaneous.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 14/Dec/09 ]

I can't reproduce this.
added this test: http://github.com/mongodb/mongo/commit/c6420d62e0748d5df85cc0499126c3e797c3f6cc
which seems to work fine.
if you could send the explain() or a test that shows it, would be very helpful

Comment by auto [ 14/Dec/09 ]

Author:

{'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: test for SERVER-486
http://github.com/mongodb/mongo/commit/c6420d62e0748d5df85cc0499126c3e797c3f6cc

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