GAE/J Is fetch all faster with 1 entity group or multiple entity groups?
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 al开发者_JAVA百科l. 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!
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.
精彩评论