Re: ORM using tons of memory and CPU

2009-12-15 Thread Jirka Vejrazka
Well, I was bound to get something wrong :) > to_be_purged = > archivedEmail.objects.filter(received__lte=newest_to_delete).values('cacheID', > flat=True) the end of the line should be .values_list('cacheID', flat=True) # not .values( Cheers Jirka -- You received this message

Re: ORM using tons of memory and CPU

2009-12-15 Thread Jirka Vejrazka
Hi, correct me if I got it wrong, but you essentially need these 4 things: 1) obtain the date for the the newest messages to delete 2) get cacheID of all objects to be deleted 3) delete the files 4) delete these objects from the database So, you could use something like this: # get the

Re: ORM using tons of memory and CPU

2009-12-15 Thread Tracy Reed
On Tue, Dec 15, 2009 at 03:35:29AM -0800, bruno desthuilliers spake thusly: > looks like settings.DEBUG=True to me. Nope. settings.py has DEBUG = False > wrt/ the other mentioned problem - building whole model instances for > each row - you can obviously save a lot of work here by using a >

Re: ORM using tons of memory and CPU

2009-12-15 Thread Tracy Reed
On Tue, Dec 15, 2009 at 09:43:02AM +0200, Jani Tiainen spake thusly: > If you have DEBUG=True setting Django also records _every_ SQL query > made to database and depending on a case, it might use quite lot of > memory. My settings.py contains: DEBUG = False -- Tracy Reed http://tracyreed.org

Re: ORM using tons of memory and CPU

2009-12-15 Thread bruno desthuilliers
On 15 déc, 02:44, Tracy Reed wrote: > I have code which looks basically like this: > > now        = datetime.today() > beginning  = datetime.fromtimestamp(0) > end        = now - timedelta(days=settings.DAYSTOKEEP) > > def purgedb(): >     """Delete archivedEmail objects

Re: ORM using tons of memory and CPU

2009-12-15 Thread rebus_
2009/12/15 Tracy Reed : > > I have code which looks basically like this: > > now        = datetime.today() > beginning  = datetime.fromtimestamp(0) > end        = now - timedelta(days=settings.DAYSTOKEEP) > > def purgedb(): >    """Delete archivedEmail objects from the

Re: ORM using tons of memory and CPU

2009-12-14 Thread Jani Tiainen
On Mon, 2009-12-14 at 17:44 -0800, Tracy Reed wrote: > I have code which looks basically like this: > > now= datetime.today() > beginning = datetime.fromtimestamp(0) > end= now - timedelta(days=settings.DAYSTOKEEP) > > def purgedb(): > """Delete archivedEmail objects from

Re: ORM using tons of memory and CPU

2009-12-14 Thread fordprefect
Try using a) queryset.iterator() to iterate through the results and b) paginating the results. Otherwise you run the risk of loading all the results into memory at once, On Dec 15, 1:44 am, Tracy Reed wrote: > I have code which looks basically like this: > > now        =

ORM using tons of memory and CPU

2009-12-14 Thread Tracy Reed
I have code which looks basically like this: now= datetime.today() beginning = datetime.fromtimestamp(0) end= now - timedelta(days=settings.DAYSTOKEEP) def purgedb(): """Delete archivedEmail objects from the beginning of time until daystokeep days in the past."""