com*_*tta 4 google-app-engine google-cloud-datastore
我对之字形合并联接算法有疑问。在https://developers.google.com/appengine/articles/indexselection文章中,提到
Index(Photo, owner_id, -date), 
Index(Photo, size, -date)
Run Code Online (Sandbox Code Playgroud)
可以结合成为
Index(Photo, owner_id, size, -date) ;
Run Code Online (Sandbox Code Playgroud)
我的测试如下:
  <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>
Run Code Online (Sandbox Code Playgroud)
我之所以向您发送电子邮件是因为,当我在开发和生产环境中尝试此操作时,它不起作用,并且需要具有每个单独的索引。可以详细说明吗?
app引擎中的之字形合并联接算法通过合并通过扫描按相同属性排序的较小的较小索引而得出的结果,以提供这些索引共有的结果,从而有助于减少所需的索引。因此,在google文档中给出的示例中,on的索引owner_id的排序顺序为on date(desc),而on的索引size的排序顺序为   date(desc)。因此,对于这两个属性以及相同的排序顺序date(desc)进行查询,可以避免使用额外的组合索引,因为之字形合并将使用2个单独的索引查找结果。
在您的示例中,这两个索引无法合并,因为它们未在同一属性上排序,因此对于您的查询,您将需要一个对应的索引。我将使用您的数据给出一个虚构的示例,其中可以使用之字形合并连接:
如果您的2个索引与上面的一样,都按排序hideIt(asc),那么如果您有一个查询,voteCount,createdByDate,hideIt  则不需要此组合的其他索引,并且2个现有索引将满足您的目的。
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           1506 次  |  
        
|   最近记录:  |