Thanks Jawaad!

On Mon, May 3, 2010 at 8:26 PM, Jawaad Mahmood <jawaad.mahm...@gmail.com>wrote:

> I had to deal with the same issue myself.
>
> I did this:
>
> class DeleteFull():
>    def execute(self):
>        deleting = model_class_name.all().order('__key__').fetch(100)
>        while deleting:
>            a = []
>            key = deleting[-1].key()
>            for item in deleting:
>                a.append(item)
>            db.delete(a)
>            deleting = model_class_name.all().filter('__key__ >',
> key).order('__key__').fetch(100)
>
> This purged everything, but it took a hell of a long time.
>
>
> On Tue, May 4, 2010 at 11:08 AM, Patrick Twohig
> <patr...@namazustudios.com> wrote:
> > Recently, I have refactored my code such that I no longer need entities
> of a
> > particular kind.  I was curious how I would go about writing a task to
> > delete these entities in bulk.  I have set up a task that performs a
> query
> > specifying only the kind, and then using a cursor to delete the entities
> on
> > the task queue.  However, when I run the task it seems to complete
> > prematurely rather than delete all entities.
> >
> > Here's the process I use:
> >
> > I perform a query for all entities of a particular kind.  For instance
> > "SELECT * FROM SomeKind" or new Query("SomeKind") in Java.
> > I delete as many entities as I can using the results of the query until I
> > hit a soft deadline.  I set that up myself to be 10 seconds, or so.
> > If there are more results left, I generate a cursor and pick up again and
> > re-queue the task to execute again.
> > If there are no results left, I just leave finish the task logging the
> > result.
> >
> > The problem is, the task seems to finish prematurely and it appears to
> > either delete only a few hundred entities, or it simply skips a few here
> and
> > there.  Running it in the debugger, it all seems to work well, but on the
> > AppEngine it doesn't seem to work quite as well.  Any thoughts or
> > suggestions?
> >
> > Thanks,
> > Patrick.
> >
> > --
> > Patrick H. Twohig.
> >
> > Namazu Studios
> > P.O. Box 34161
> > San Diego, CA 92163-4161
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-appeng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/google-appengine?hl=en.
> >
>
>
>
> --
> Sincerely yours,
>
> Jawaad Mahmood
> http://www.jawaadmahmood.com
> 080-4204-7198
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to google-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>


-- 
Patrick H. Twohig.

Namazu Studios
P.O. Box 34161
San Diego, CA 92163-4161

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to