列表属性如何影响 Google App Engine 中每个实体的索引条目?
我知道每个实体有 5000 个索引条目的限制,这 意味着我不能做这样的事情:
class Foo(db.Model):
x = db.ListProperty(int)
y = db.ListProperty(int)
foo1 = Foo(x = range(5001))
foo1.put()
此外,如果我在index.yaml中有索引
- kind: Foo
properties:
- name: x
- name: y
,那么我也可以从这个线程中看到:
http://groups.google.com/group/google-appengine/browse_thread/thread/d5f4dcb7d00ed4c6
我不能这样做:
foo2 = Foo(x = range(100), y=range(100))
foo2.put()
因为这会给我10,000 个索引条目。
但是,我的问题是:如果我在 index.yaml 中没有任何条目 Foo 并尝试:
foo3 = Foo(x = range(100), y=range(100))
foo3.put()
这仍然会引发“BadRequestError:索引属性太多” 对于实体”异常?从我的测试来看,它看起来不会导致任何 错误。这是正确的吗? foo3 有多少个索引条目 这个案子?是200(每个列表的长度之和)吗?或者 还有什么吗?
I know that there is a limit of 5000 index entries per entity, which
means I can't do things like this:
class Foo(db.Model):
x = db.ListProperty(int)
y = db.ListProperty(int)
foo1 = Foo(x = range(5001))
foo1.put()
Furthermore, if I have the index in index.yaml
- kind: Foo
properties:
- name: x
- name: y
then I also see from this thread:
http://groups.google.com/group/google-appengine/browse_thread/thread/d5f4dcb7d00ed4c6
that I can't do this:
foo2 = Foo(x = range(100), y=range(100))
foo2.put()
because that would give me 10,000 index entries.
However, my question is: if I DON'T have any entries in index.yaml for
Foo and try:
foo3 = Foo(x = range(100), y=range(100))
foo3.put()
will that still raise the "BadRequestError:Too many indexed properties
for entity" exception? From my tests, it looks like it won't cause any
errors. Is this correct? How many index entries would foo3 have in
this case? Is it 200 (the sum of the lengths of each list)? Or
something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的 - 这不会引发任何异常,并且会创建 200 个索引条目。
对于复合索引的工作方式是,为每个唯一的值组合创建一个索引行,而内置索引为每个值创建一个索引行 - 它们相当于在您的每个属性上定义一个单独的单属性索引。模型。
You're correct - this won't raise any exceptions, and it will create 200 index entries.
The way this works for composite indexes is that one index row is created per unique combination of values, whilst built-in indexes create one index row per value - they're equivalent to having a separate single-property index defined on every property in your model.