1

I have an Entity called Movie.

I want to have a get_or_create method for the Movie entity. Right now each Movie entity is in its own Entity group.

I read I have to put them in the same entity group and use transactions to avoid duplicate entities.

I could also perhaps choose my own unique key which would result in overwriting a few entries (idempotent) without any effect.

The movies count can be from 1-50000. At some point I want to fetch them all. Would it be faster executing a query against a single entity group or multiple entity groups? Is it faster because an entire entity group is stored in a specific node?

My requirement is fast read of all the movies.

Thanks!

dnkoutso
  • 6,041
  • 4
  • 37
  • 58

1 Answers1

0

I read I have to put them in the same entity group and use transactions to avoid duplicate entities.

This is not the case. Using a key name, as you suggest, to prevent duplicates by ensuring that would-be duplicates have the same key name.

Entity groups should only be used for transactions, and should be kept as small as possible, as updates to an entity group are limited to roughly 1 per second.

The movies count can be from 1-50000. At some point I want to fetch them all. Would it be faster executing a query against a single entity group or multiple entity groups?

Entity groups will not affect the speed of this query - either way, the query will first look up the entities in an index, then fetch them (in parallel) and return them to you.

Bear in mind that fetching 50,000 entities is going to be slow no matter what you do. Avoid doing that if you can.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
  • http://khaidoan.wikidot.com/google-app-engine-datastore-entity-group Number 2 at the bottom says "Also, multiple users attempting to update entities in the same entity group at the same time will cause some users to retry their transactions, possibly causing some to fail to commit changes. Do not put all of the application's entities under one root." Are you referring to the idempotent entity? How come you mention that the same entity group won't help with duplicate entries? Is it because i use my own unique key? – dnkoutso Aug 15 '11 at 05:42
  • @dnkoutso I'm referring to any entity group - idempotence is irrelevant. Entity groups won't help with duplicates because an entity's key name is only unique within other entities with the same parent - so it's just as easy to ensure uniqueness across root entities as it is within an entity group. – Nick Johnson Aug 15 '11 at 10:04