GAE/J 使用 1 个实体组还是多个实体组,获取速度更快吗?
我有一个名为电影的实体。
我想要为 Movie 实体提供一个 get_or_create 方法。现在,每个电影实体都位于其自己的实体组中。
我读到我必须将它们放在同一个实体组中并使用事务来避免重复的实体。
我也许还可以选择自己的唯一密钥,这将导致覆盖一些条目(幂等)而没有任何效果。
电影数量可以从 1 到 50000。在某个时候我想把它们全部取出来。针对单个实体组或多个实体组执行查询会更快吗?是不是更快,因为 整个实体组存储在特定节点中?
我的要求是快速阅读所有电影。
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实并非如此。按照您的建议,使用键名称来通过确保可能的重复项具有相同的键名称来防止重复。
实体组应仅用于事务,并且应尽可能小,因为实体组的更新限制为大约每秒 1 次。
实体组不会影响此查询的速度 - 无论哪种方式,查询都会首先在索引中查找实体,然后(并行)获取它们并将它们返回给您。
请记住,无论您做什么,获取 50,000 个实体都会很慢。如果可以的话,避免这样做。
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.
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.