_Nik
On 11/22/2011 2:37 PM, Nan wrote:
Hi folks -- I need to run a fairly CPU-intensive calculation nightly over a dataset that's already large and growing quickly. I'm planning to run this via a cron job, but would like to make sure that it neither eats up the entire CPU nor locks the database, so that my site can continue functioning in the meantime. The rough outline of what it needs to do is as follows: class OtherThing(models.Model): anotherthing = models.ManyToManyField(Whatever) ... class Thing(models.Model): other_things = models.ManyToManyField(OtherThing, through='SomethingElse') ... for thing in Thing.objects.select_related('other_things', 'other_things__anotherthing__etc'): calculated = calculation_on_thing_and_its_otherthings(thing) # this mainly involves serialization to a great depth thing.calculated_data = calculated thing.save() Will the above approach lock the database for a while or eat tons of CPU? Any suggestions? I'm using Django 1.2, btw. Thanks, -Nan
No comments:
Post a Comment