1

I'm trying to delete 300 000 entities in GAE (java), using this:

 PersistenceManager pm = PMF.get().getPersistenceManager();

 Date date70DaysAgo = Calendar.getInstance().getTime();
 date70DaysAgo.setDate(date70DaysAgo.getDate()-70);

 Query query = pm.newQuery(PositionApplication.class);
 query.setFilter("date <= yyy");
 query.declareParameters("java.util.Date yyy");
 query.setRange(0,750);
 Collection<PositionApplication> elements = (Collection<PositionApplication>)query.execute(date70DaysAgo);

 pm.deletePersistentAll(elements);

I'm limited to 50 000 write ops a day (free quota). I naively thought that in 6-7 days it should be done, but it appears that 1 call uses 1/5 of the daily quota.

--> Datastore Write Operations 21%      0.01 of 0.05 Million Ops

10 000 write ops, why not 750?

Is it related to indexes?

Francois
  • 10,730
  • 7
  • 47
  • 80

1 Answers1

1

When you delete an entity, the datastore also has to delete the per-property indexes and any entries in the composite indexes.

The calculation for the deletion of each entity is:

2 Writes + 2 Writes per indexed property value + 1 Write per composite index value

See the Billing and Budgeting Resources document for the calculations of all datastore operations.

Simon
  • 190
  • 3
  • ok... so how can I delete all the records... because delete in datastore admin eat my quota as well...? – Francois Feb 12 '12 at 16:42
  • Unfortunately there is no cheap or easy option to this. You either enable billing, and delete the data for a small cost without hitting quota limits, or you slowly delete the data. – Simon Feb 12 '12 at 22:49
  • I have deleted all indexes on this entity, restricted access to the web app, and I will deleted them by hand, 25 000 each day... – Francois Feb 13 '12 at 10:36