java - Is there any performance risk in having transactions wrap every datastore event in App Engine - reads and writes? -


According to app engine docs, you wrap a datestore event in such transactions:

  

Import javax.jdo.Transaction; Import Clomombers; // not shown // ... // continuity manager = pm ...; Transactions Tx = BBC. Transaction (); Try {tx.begin (); Club member members = pm.getObjectById (ClubManers category, "12345"); Members.incrementCounterBy (1); Pm.makePersistent (member); Tx.commit (); } Finally {if (tx.isActive ()) {tx.rollback (); }}

If you are wrapped up in every reading program, not every event you write in the transaction, will it negatively affect the performance of the application?

The transaction is definitely overhead for reading and writing.

It does not understand in many cases - if you are just reading a value from a datastore, then there is no benefit by wrapping a single reading operation in one transaction. When you have a set of more than one operation, for which it is necessary to work together, then secure the transaction (i.e., receive, increment, continue on being included in your example) in the GAE documentation Section that you can get help on.

In addition, for batch datastore operations, it is often easier to reduce the number of rounds between your application and datastore. If you wrap every operation in every transaction, you will need to send each transaction individually (which is very slow, especially if you sync each request).


Comments