Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top