google-app-engine - Appengine ZigZag Merge Join Algo

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

我对之字形合并连接算法有疑问。在文章中https://developers.google.com/appengine/articles/indexselection , 提到

Index(Photo, owner_id, -date), 
Index(Photo, size, -date)

可以组合成

Index(Photo, owner_id, size, -date) ;

我的测试如下:

  <datastore-index kind="KindTest1" ancestor="false" source="auto">
        <property name="hideIt" direction="asc"/>
        <property name="voteCount" direction="desc"/>
    </datastore-index>

    <datastore-index kind="KindTest1" ancestor="false" source="auto">
        <property name="hideIt" direction="asc"/>
        <property name="createdByDate" direction="asc"/>
    </datastore-index>

can these 2 indexes combine to become,

    <datastore-index kind="KindTest1" ancestor="false" source="auto">
        <property name="hideIt" direction="asc"/>
        <property name="createdByDate" direction="asc"/>
        <property name="voteCount" direction="desc"/>
    </datastore-index>

之所以给您发送电子邮件,是因为当我在开发和生产环境中尝试这样做时,它不起作用并且需要每个单独的索引。能详细点吗?

最佳答案

App Engine 中的之字形合并联接算法有助于减少所需的索引,方法是组合通过扫描按相同属性排序的单独较小索引得出的结果,以提供这些索引共有的结果。因此,在 google 文档中给出的示例中,owner_id 上的索引在 date(desc) 上有排序顺序,在 size 上有索引具有与 date(desc) 相同的排序顺序。因此,要对这两个属性以及相同的排序顺序日期 (desc) 进行查询,可以避免使用额外的组合索引,因为之字形合并将使用 2 个单独的索引找到结果。

在您的示例中,这 2 个索引不能合并,因为它们未按同一属性排序,因此对于您的查询,您将需要一个相应的索引。我将使用您的数据给出一个虚构的示例,其中可以使用之字形合并连接:

如果你的 2 个索引像上面一样,都是按 hideIt(asc) 排序的,那么如果你有一个关于 voteCount,createdByDate,hideIt 的查询,那么你不需要此组合需要一个额外的索引,而 2 个现有索引将满足您的目的。

关于google-app-engine - Appengine ZigZag Merge Join Algo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17386409/

相关文章:

python - 尝试递增 db.IntegerProperty 时出错 : TypeError: can only concatenate tuple (not "int") to tuple

javascript - 从 Chrome 扩展程序到 App Engine 的 POST 请求作为 GET 请求收到

java - Google App Engine 低级 api - 将自定义对象保存为 Blob?

java - 我如何知道哪些代码可以用于 GWT 的客户端实现?

java - GAE/J - JPA 错误 - 类型 ("")不是实体的,但需要用于此操作

java - Google 云端硬盘服务帐户返回 403 usageLimits

java - Appengine Python 数据存储区查询是否比 Java 慢很多(> 3 倍)?

google-app-engine - GAE Go 测试 - 数据存储查询在测试环境中是否有效?

php - 从 PHP 访问 Google App Engine 的搜索 API

python - 如何将值为 True 的数据存储中的所有属性移动到另一个数据存储?