Nithin
Nithin

Reputation: 5840

Understanding Entity group limitations

I am trying to understand how to tackle there two limitations of google datastore

write throughput limit of about one transaction per second for a single entity group.

All the data accessed by a transaction must be contained in at most 25 entity groups.

suppose I wanted to store users info. Due to the 1st limitation I cant store them in a entity group, as several users may update their info at same time. Now if i try to save all users as root entities the 2nd limitation says i cant use any query on users (like find a user whose age > 10). Now i am wondering how is datastore even usable with such limitations.

Upvotes: 1

Views: 123

Answers (2)

Dan Cornilescu
Dan Cornilescu

Reputation: 39814

You're misinterpreting the 2nd limitation: you can, of course, query all users for those whose age > 10, only you must not do it inside a transaction.

If consistency is important you can:

  1. perform a keys-only query outside a transaction
  2. obtain a list of up to 25 keys to operate on (for example by using Query Cursors)
  3. inside a transaction access (by key) the entities corresponding to the keys in your list - these accesses will be consistent

Upvotes: 2

Greg
Greg

Reputation: 10360

A query isn't a transaction - the returned results can be spread across any number of entity-groups.

Upvotes: 1

Related Questions