Monday, November 28, 2011

Re: Large Queryset Calculation In Background?

On Mon, Nov 28, 2011 at 2:54 PM, Nan <ringemup@gmail.com> wrote:
>
> We're using MySQL 5 (don't know off the top of my head what specific
> release).  I don't think a master/slave DB configuration is something
> we can manage to set up at this point.
>
> Querysets are fetched from the database in chunks, right?  I imagine
> that the select itself is actually quite quick, but do the tables
> remain locked between chunks?  I.e. if the query returns a total of N
> records and Django fetches N/10 records and then performs a bunch of
> calculations and saves before returning to the DB for another N/10
> records, will the DB be locked during all those calculations/saves?
>

Well, it depends upon the database, but no, it doesn't work like that.

With MySQL, the query will cause the server to lock the table until
the client has finished reading all of the result. There are then two
modes to read the result from the server, row-by-row or all-at-once.
Django currently always fetches the entire result all at once,
regardless of how you then fetch the data from the queryset.

Cheers

Tom

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment