django-nonrel / mongodb-engine

Django MongoDB Backend
http://www.django-nonrel.org/
863 stars 211 forks source link

Mongodb-engine not caching QuerySets? #117

Open ablegrape opened 12 years ago

ablegrape commented 12 years ago

Something I've noticed about Mongodb-engine (or is it a general django-nonrel issue) versus the "standard" Django:

If I do:

>>> my_qs = MyClass.objects.filter(<some_very_expensive_query>)

Django comes back immediately, with or without Mongodb, because it hasn't evaluated the QuerySet yet.

Then if I do:

>>> my_result = my_qs[0]

Here, I wait a few seconds, with or without Mongodb. Again, this is expected; I forced Django to evaluate the QuerySet.

But if I then do:

>>> my_second_result = my_qs[1]

In "normal" Django, this returns immediately, since Django has already evaluated the QuerySet and cached at least a chunk of it. With mongodb-engine, I wait a few seconds again; it's clear that Django is re-evaluating the QuerySet every time I access an element.

Is this the expected behavior? If so, it seems like a serious performance problem because it breaks the expected behavior of Django. Or am I misunderstanding or doing something wrong? I couldn't find anything on the Django-nonrel group list about this, but it seems like it must be a known issue.

jonashaag commented 12 years ago

I can confirm this. It's definitely a bug, patches/tests welcome.

Alir3z4 commented 11 years ago

Is this bug have fixed?

aburgel commented 11 years ago

The issue is still open, so I doubt anyone has made a fix. Are you still experiencing the issue, which version of mongodb-engine are you using?

Alir3z4 commented 11 years ago

@aburgel Well no, I've not experienced this issue yet, I just see this issue. But I'll try to reproduce it. I'm using 1.5-beta also.

Thanks for your reply ;)