Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Google classify as a datastore write operation in Google App Engine?

Since GAE went to the pricing model at the start of last week I have been wrestling with exceeding my quota of Datastore read and write operations. I'm not sure whether Google counts all updates for one writer as one write or whether every column update is counted as a separate write.

If the latter is true could I get around this by having one update function to update the 6 columns in the parameters or do will I also get charged for 6 updates?

Here is my existing code, used to update a player's score (rating) and the other details at the same time. At the moment I always populate name, email, rating, won, played and achievements with values from the client. One solution may be to only send these from the client side when they have changed value.

Long key = Long.valueOf(updateIdStr);
System.out.println("Key to update: " + key);
PlayerPersistentData ppd =null;
try {
    ppd = pm.getObjectById(
    PlayerPersistentData.class, key);
// for all of these, make sure we actually got a value via
// the query variables
    if (name != null && name.length() > 0) {
        ppd.setName(name);
}

if (ratingStr != null && ratingStr.length() > 0) {
    ppd.setRating(rating);
}

if (playedStr != null && playedStr.length() > 0) {
     ppd.setPlayed(played);
}

if (wonStr != null && wonStr.length() > 0) {
     ppd.setWon(won);
}

if (encryptedAchievements != null
    && encryptedAchievements.length() > 0) {
    ppd.setAchievements(achievements);
}

if (email != null & email.length() > 0) {
    ppd.setEmail(email);
}

resp.getWriter().print(key);
} catch (JDOObjectNotFoundException e) {
    resp.getWriter().print(-1);
}
        }
like image 604
Barry Irvine Avatar asked Nov 13 '11 17:11

Barry Irvine


1 Answers

The number of writes you are charged for depends on your entity. In general, you are charged for 1 write for the entity, and 1 write for each index update. Each indexed property is included in the ascending and descending single-property indexes, so there's a minimum of 2 writes per indexed entity, plus any writes for composite (user-defined) indexes.

When updating an existing entity, you're charged for the diff of the old indexes and the new ones. So if you modify one property, you'll be charged for the entity write, plus 4 writes per property (deleting the old value and inserting the new one) for the built-in indexes, and likewise for any composite indexes.

like image 163
Nick Johnson Avatar answered Oct 11 '22 17:10

Nick Johnson