Appengine ZigZag合并加入算法 [英] Appengine ZigZag Merge Join Algo

查看:69
本文介绍了Appengine ZigZag合并加入算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have question on zigzag merge join algorithm. In article https://developers.google.com/appengine/articles/indexselection , mentioned

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>

原因之所以给您发送电子邮件是因为,当我在开发和生产环境中尝试此操作时,它不起作用,并且需要具有每个单独的索引.可以详细说明吗?

Reason I email you because when i try this on dev and production, it does not work and required to have each separate indexes. Can elaborate more ?

推荐答案

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

The zig-zag merge join algorithm in app engine helps to reduce the required indexes by combining the results derived by scanning separate smaller indexes that are sorted by the same property, to give results that are common to these indexes. So in the example given in the google documentation, the index on owner_id is having a sort order on date(desc) and the index on size is having the same sort order of date(desc). Hence for doing a query on both these properties together with same sort order date(desc), an additional combined index can be avoided, as zigzag merge will find the results using the 2 separate indexes.

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

In your example, the 2 indexes cannot be combined as they are not sorted on the same property and hence for your query you will need a corresponding index. I will give a fictious example using your data, where zigzag merge join can be utilised :

如果您的2个索引与上面的一样,都按hideIt(asc)排序,那么如果您对voteCount,createdByDate,hideIt进行查询,则不需要此组合的其他索引,并且2个现有索引将满足您的目的.

If your 2 indexes were like above, that is both sorted by hideIt(asc), then if you have a query on voteCount,createdByDate,hideIt then you dont need an additional index for this combination and the 2 existing indexes will serve your purpose.

这篇关于Appengine ZigZag合并加入算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆