Your suggestion about iterator is just what I was looking for!
values_list() is also good to know about.
Many thanks!
On Dec 28 2008, 10:39 pm, "join.toget...@gmail.com"
wrote:
> Three things:
>
> 1:http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator
>
Three things:
1: http://docs.djangoproject.com/en/dev/ref/models/querysets/#iterator
2: What you're trying to do can be done much more efficiently the
following way: sum(SomeModel.objects.all().values_list('value'))
3: django 1.1 will have aggregation support, meaning you won't even
need to do
Or, if the issue is at least partly due to buffering for efficiency in
communicating between django and the database engine, is there a way
to choose to have smaller buffers?
On Dec 24, 12:42 pm, garyrob wrote:
> I am getting the impression that when I do a django database
I am getting the impression that when I do a django database query
that iterates through all the rows of the table, django stores every
model instance in memory.
For instance, just doing
sumValues = 0
for someModel in SomeModel.objects.all():
sumValues += someModel.value
print sumValues
4 matches
Mail list logo