google-app-engine - 数据存储中真的需要索引吗?

标签 google-app-engine google-cloud-datastore

我对一些 GAE 文档感到有点困惑。虽然我打算添加索引来优化我的应用程序的性能,但我想澄清一下它们是仅建议用于此目的还是确实需要。

Queries can't find property values that aren't indexed. This includes properties that are marked as not indexed, as well as properties with values of the long text value type (Text) or the long binary value type (Blob).

A query with a filter or sort order on a property will never match an entity whose value for the property is a Text or Blob, or which was written with that property marked as not indexed. Properties with such values behave as if the property is not set with regard to query filters and sort orders.

来自 http://code.google.com/appengine/docs/java/datastore/queries.html#Introduction_to_Indexes

第一段让我相信您根本无法对未索引的属性进行排序或过滤。但是,第二段让我认为此限制仅局限于 Text 或 Blob 属性或特别注释为未索引的属性。

我对这种区别很好奇,因为我有一些数字和字符串字段,我目前在生产环境中根据这些字段进行排序/过滤,这些字段未编制索引。这些查询在后台任务中运行,该任务大多不关心性能(在此情况下宁愿针对大小/成本进行优化)。我是否幸运地返回了正确的数据?

最佳答案

在 GAE 数据存储中,会自动为所有不可索引(明确标记或那些类型)的属性创建单个属性索引。

我想,该文档中的语言有点令人困惑。

只有当您希望按多个属性进行索引时(例如,按两个不同的属性进行排序),您才需要显式定义索引。

关于google-app-engine - 数据存储中真的需要索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4732503/

相关文章:

python - 将 GAE BlobInfo 转换为文件对象

java - 多列上的 DISTINCT 查询不起作用 - Google App Engine 数据存储区

google-app-engine - 如何从我的 Compute Engine VM 访问我的 AppEngine DataStore 实体?

java - 如何使用 Java 库根据数组属性过滤 Google Content Store 数据

python - Facebook 使用 GET 而不是 POST 调用 Google App Engine 代码

image - Google App Engine 上的用户个人资料图片组织

php - gae 本地环境未运行 WordPress 最新版本,仅适用于 3.5.1

google-app-engine - 身份 Google App Engine 环境类型

python - 如何在 Google App Engine 中使用 python 从我们要在 ndb 数据存储中搜索的元素列表中进行 AND & OR 运算查询

python - 失败的 ndb 事务尝试不回滚所有更改?