Hi,

If it is a one time thing, the easiest is to use imacro plugin for
firefox (or similar). Just teach it to use the GAE admin to delete the
entities  (20 per page) and then replay it in a lot of loops. This
takes one minute to set up and works perfectly.

Cheers,
Tobias

On Mar 13, 9:44 am, 杨浩 <[email protected]> wrote:
> *In my store,have more than 100,000 entities here,but i find delete(limit
> 400) it's cost > 26s*
> my datas is wrong so i must delete all entities of the kind(no index in the
> kind)!
>
> *1. first i use:*
> Query q = pm.newQuery(query);
>                        q.setRange(0, 400);
> int count = 0;
>                        try {
>                                resultList = (List<T>) q.execute();
>                                for (T t : resultList) {
>                                        pm.deletePersistent(t);
>                                        count++;
>                                }
>                                return count;
>                        } finally {
>                                q.closeAll();
>                        }
> I found that:every time it's delete only few entity(<100)!(I watch 200
> entities of the kind with GAE Datastore Viewer)
>
> *2 second i use:*
>
> UtilGAE.howTimer(true),return how time cost with a threadlocal var store a
> start millionseconds,arg is a flag(true if cost time>26second throw a
> IllegalStateException("it's cost more than limit 26s");
>
> DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
>         Query query = new
> Query(Section.class.getSimpleName()).setKeysOnly();
>         int count = 0;
>         try {
>             Iterable<Entity> iter =
> ds.prepare(query).asIterable(FetchOptions.Builder.withLimit(400));
>             logger.info("query cost time:{}s",
> UtilGAE.howTimer(true)/1000d);
>             for (Entity entity : iter) {
>                 Key key = entity.getKey();
>                 ds.delete(entity.getKey());
>                 count++;
>                 UtilGAE.howTimer(true);
>             }
>             if (count != 0) throw new IllegalStateException("next continue
> to delete...");
>         } finally {
>             logger.info("delete:{},cost time:{}s", count,
> UtilGAE.howTimer()/1000d);
>         }
> so it's work fine(it's real delete entity from my store) and a most of cost
> time in the 26s!
>
> I say there have most of limited in the GAE Stored!you must to be carefull
> when you have a larger datastore!
>
> 2010/3/12 Toby <[email protected]>
>
> > Hello,
>
> > deleting 500 should not take a lot of time. Did you try the
> > deletePersistentAll method?
> >                        Query q = pm.newQuery(persistentClass);
> >                        q.deletePersistentAll();
>
> > otherwise what I do is using the task queue. I delete 1000 entities
> > and then put a task in the queue to delete another 1000. In that case
> > you can not use the deletePersistentAll. You need to query by object
> > type and limit:
>
> >                        Query q = pm.newQuery(query);
> >                        q.setRange(0, size);
>
> >                        try {
> >                                resultList = (List<T>) q.execute();
> >                                resultSize = resultList.size();
> >                                for (T t : resultList) {
> >                                        pm.deletePersistent(t);
> >                                }
> >                                return resultSize;
> >                        } finally {
> >                                q.closeAll();
> >                        }
>
> > since I return the size I see how much records where affected. If it
> > is less than 1000 I know that I can stop doing the queuing.
> > This is a bit difficult to set up but works fine. I believe there is
> > not better way to do that but I am happy about any other suggestions.
>
> > Cheers,
> > Toby

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to