避免默认索引但在 AppEngine 中保留显式定义的索引?
我有一些属性仅在需要复合索引的查询中引用。 AppEngine 将所有索引属性写入其自己的特殊索引,这需要每个属性进行 2 次额外的写入操作。
有没有什么方法可以指定属性不在其自己的索引中建立索引,但仍用于我的复合索引?
例如,我的实体可能是具有属性 name
和 group
的 Person。我的代码中唯一的查询是 select * from Person where group =
name
上创建了一个索引,在 group
上创建了一个索引,这使得写入每个实体所需的写入操作数量增加了三倍!
我可以从文档中看到如何完全阻止属性用于索引,但我只想关闭少数索引(默认索引)的索引。
I have some properties that are only referenced in queries that require composite indices. AppEngine writes all indexed properties to their own special indexes, which requires 2 extra write operations per property.
Is there any way to specify that a property NOT be indexed in its own index, but still be used for my composite index?
For example, my entity might be a Person with properties name
and group
. The only query in my code is select * from Person where group = <group> and name > <name>
, so the only index I really need is with group ascending and name ascending. But right now AppEngine is also creating an index on name
and an index on group
, which triples the number of write operations required to write each entity!
I can see from the documentation how to prevent a property from being used for indexing at all, but I want to turn off indexing only for a few indexes (the default ones).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我目前的了解,您可以一起禁用属性上的索引(包括复合索引),或者您必须拥有所有索引(自动索引+来自index.yaml的复合索引)。
GAE 谷歌小组对此进行了一些讨论,并提出了一个功能请求,要求完全按照您的建议进行操作,但我无法找到它。当我回家并搜索更多内容时会更新答案。
From what I understand currently, you can either disable indexing on a property all together (which includes composite indexes) or you are stuck with having all indexes (automatic indexes + your composite indexs from index.yaml).
There was some discussion about this in the GAE google group and a feature request to do exactly what you are suggesting, but I wasn't able to find it. Will update the answer when I get home and search more.