Hi, I've recently read Malcolm's blog entry about __iter__ and __len__ in the refactored QuerySets. Interesting!
In the refactored QuerySet, if you do e.g. if models.Something.objects.all(): ... then QuerySet.__nonzero__ will execute the query and try to fetch the first result. I see one possible problem: I observe that mysql always slurps in the whole result set from the database when you only issue a select (cursor.query(...)) If you dig into MySQLdb, you see how it happens at cursor.py (of MySQLdb): Cursor.execute() calls Cursor._query() Cursor._query() calls Cursor._do_query() Cursor._do_query() calls _do_get_result() ... which eventually fetches all (!) results from MySQL. Mysql provides a CursorUseResultMixIn, but this has the restriction that "You MUST retrieve the entire result set and close() the cursor before additional queries can be peformed on the connection." ... and that's not what we want, either. Theoretically, it's probably possible to work around this, since the C API has a function to free the result set. Another solution could be to let the database backend decide whether it's better to use count() instead. Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---