Loading...
Loading...
I create simple test similar described in docs (http://www.mongodb.org/display/DOCS/Multikeys) for problem demonstration: My comment added in output with " ------------------- from pymongo.connection import Connection from pprint import pprint connection = Connection("localhost", 27017) db = connection.test db.create_collection("example") example list is [[1,2,3,4,5],[4,5,6,7,8],[7,8,9,10,11],[10,11,12,13,14]...] samples = [range(i, i+5) for i in xrange(1, 10000, 3)] for item in samples: db.example.save( {"test":item} ) db.example.ensure_index("test",1) query = {"test":{"$in":[1,100,9000]}} print "Result:" pprint(list(db.example.find(query))) print "\nQuery Explain:" explain = db.example.find(query).explain() pprint(dict(explain.items())) ---------------------------- After run it, I receive explain output: ...... {u'allPlans': [{u'cursor': u'BtreeCursor test_1', u'endKey': {u'test': 9000} , u'startKey': {u'test': 1}}], u'cursor': u'BtreeCursor test_1', u'endKey': {u'test': 9000} , u'millis': 25, u'n': 4, u'nscanned': 14998.0, u'oldPlan': {u'cursor': u'BtreeCursor test_1', u'endKey': {u'test': 9000} , u'startKey': {u'test': 1}}, u'startKey': {u'test': 1}} ------------- When I try to get records without IN explain = db.example.find( {"test":9000} ).explain() pprint(dict(explain.items())) result look as: {u'allPlans': [{u'cursor': u'BtreeCursor test_1', u'endKey': {u'test': 9000} , u'startKey': {u'test': 9000}}], u'cursor': u'BtreeCursor test_1', u'endKey': {u'test': 9000} , u'millis': 0, u'n': 1, u'nscanned': 1.0, u'oldPlan': {u'cursor': u'BtreeCursor test_1', u'endKey': {u'test': 9000} , u'startKey': {u'test': 9000}}, u'startKey': {u'test': 9000}} It's a normal behavior?
eliot commented on Thu, 30 Jul 2009 17:23:31 +0000: closed since resolved and no activity in 2 weeks. re-open if still issues. eliot commented on Mon, 6 Jul 2009 07:13:25 +0000: It uses the index, but right now is stupid and looks at the entire range. We've got another case open to fix it SERVER-100 you could watch that.
Click on a version to see all relevant bugs
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.