Filter out index scan for pymongo cache
This commit is contained in:
parent
940dfff625
commit
1a54dad643
@ -190,9 +190,6 @@ class query_counter(object):
|
|||||||
def __eq__(self, value):
|
def __eq__(self, value):
|
||||||
""" == Compare querycounter. """
|
""" == Compare querycounter. """
|
||||||
counter = self._get_count()
|
counter = self._get_count()
|
||||||
# Temp debugging to try and understand intermittent travis-ci failures
|
|
||||||
if value != counter:
|
|
||||||
print [x for x in self.db.system.profile.find()]
|
|
||||||
return value == counter
|
return value == counter
|
||||||
|
|
||||||
def __ne__(self, value):
|
def __ne__(self, value):
|
||||||
@ -225,6 +222,7 @@ class query_counter(object):
|
|||||||
|
|
||||||
def _get_count(self):
|
def _get_count(self):
|
||||||
""" Get the number of queries. """
|
""" Get the number of queries. """
|
||||||
count = self.db.system.profile.find().count() - self.counter
|
ignore_query = {"ns": {"$ne": "%s.system.indexes" % self.db.name}}
|
||||||
|
count = self.db.system.profile.find(ignore_query).count() - self.counter
|
||||||
self.counter += 1
|
self.counter += 1
|
||||||
return count
|
return count
|
||||||
|
@ -631,14 +631,13 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
self.assertEqual(q, 1) # 1 for the insert
|
self.assertEqual(q, 1) # 1 for the insert
|
||||||
|
|
||||||
Blog.drop_collection()
|
Blog.drop_collection()
|
||||||
|
Blog.ensure_indexes()
|
||||||
|
|
||||||
with query_counter() as q:
|
with query_counter() as q:
|
||||||
self.assertEqual(q, 0)
|
self.assertEqual(q, 0)
|
||||||
|
|
||||||
Blog.ensure_indexes()
|
|
||||||
self.assertEqual(q, 1)
|
|
||||||
|
|
||||||
Blog.objects.insert(blogs)
|
Blog.objects.insert(blogs)
|
||||||
self.assertEqual(q, 3) # 1 for insert, and 1 for in bulk fetch (3 in total)
|
self.assertEqual(q, 2) # 1 for insert, and 1 for in bulk fetch
|
||||||
|
|
||||||
Blog.drop_collection()
|
Blog.drop_collection()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user