Also, if you haven't already, I'd definitely recommend switching to  
mod_wsgi. I'm in the same boat as you – django apps on webfaction,  
running up against memory limits (to the point where I was getting my  
sites shut down); I started using mod_wsgi recently and haven't had   
any trouble since. That's three (fairly small) django apps on the  
Shared 1 plan.

Values() sounds like a pretty good idea as well, though...

Eric

On Apr 5, 2008, at 7:38 PM, Fredrik Lundh wrote:

>
> Garrett Garcia wrote:
>
>> I recently got my first django project set up on webfaction and am
>> feeling the constraint of their memory usage limits.
>> For example:
>>
>> I have a view that returns a list of objects:
>>
>> def get_meet_results(request, meet_id):
>>    meet = Meet.objects.get(pk=meet_id)
>>    year = meet.start.year
>>    result_list =  
>> Result.objects.filter(meet=meet).order_by('event','score')
>>    return render_to_response('meets/meet_results.html',
>> {'year':int(year), 'meet':meet, 'result_list':result_list})
>>
>> result_list.count() is about 1500 on average.  In the template, the
>> result list is looped through and a table row is printed for each
>> result.  This renders and loads relatively fast, but uses what  
>> seems to
>> me to be a very large amount of memory.
>
> when Django reads an object from a table, it pulls in all the fields.
> if the Result table contains some potentially large fields, you'll pay
> for those even if you're not using them in the template.  you can use
> the "values" method to control this.
>
> also note that some of those 30 megabytes might be modules that are
> pulled by the template (or by some other part of django) when you run
> the view for the first time.  to check that, tweak the query to  
> generate
> only a few hits (e.g. by slicing out the first member).
>
> </F>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to