On Nov 23, 2014, at 1:07 PM, Rick van Hattem <wo...@wol.ph> wrote:

> > Not really, cause psycopg already fetched everything.
> 
> Not if Django limits it by default :)

Unfortunately, that's not how it works.  There are three things that take up 
memory as the result of a query result:

1. The Django objects.  These are created in units of 100 at a time.
2. The psycopg2 Python objects from the result.  These are already limited to a 
certain number (I believe to 100) at a time.
3. The results from libpq.  These are not limited, and there is no way of 
limiting them without creating a named cursor, which is a significant change to 
how Django interacts with the database.

In short, without substantial, application-breaking changes, you can't limit 
the amount of memory a query returns unless you add a LIMIT clause to it.  
However, adding a LIMIT clause can often cause performance issues all by itself:

        http://thebuild.com/blog/2014/11/18/when-limit-attacks/

There's no clean fix that wouldn't have significant effects on unsuspecting 
applications.
--
-- Christophe Pettus
   x...@thebuild.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CD10DACF-4D0A-458D-BB85-0F7BB8BFF4C0%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to