泰坦文档说:
混合索引支持原生且高效的排序。但是, order().by() 方法中使用的属性键必须事先添加到混合索引中,以支持本机结果排序。这在 order().by() 键与查询键不同的情况下很重要。如果属性键不是索引的一部分,则排序需要将所有结果加载到内存中。
所以,我做了一个混合索引prop1
财产。混合指数prop1
当指定值时效果很好。
gremlin> g.V().has('prop1', gt(1)) /* this gremlin uses the mixed index */
==>v[6017120]
==>v[4907104]
==>v[8667232]
==>v[3854400]
...
但是,当我使用order().by()
on prop1
我无法利用混合索引。
gremlin> g.V().order().by('prop1', incr) /* doesn't use the mixed index */
17:46:00 WARN com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx - Query requires iterating over all vertices [()]. For better performance, use indexes
Could not execute query since pre-sorting requires fetching more than 1000000 elements. Consider rewriting the query to exploit sort orders
Also count()
需要这么长时间。
gremlin> g.V().has('prop1').count()
17:44:47 WARN com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx - Query requires iterating over all vertices [()]. For better performance, use indexes
如果我知道自己出了什么问题,我会很高兴。这是我的泰坦信息:
- 泰坦版本:1.0.0-hadoop1
- 存储后端:Cassandra 2.1.1
- 索引后端:ElasticSearch 1.7
谢谢。
您必须提供一个值来过滤要使用的索引。这里:
g.V().order().by('prop1', incr)
你没有提供任何过滤器,所以泰坦必须迭代所有V()
然后应用排序。
Here:
g.V().has('prop1').count()
您提供了一个索引键,但没有指定要过滤的值,因此它仍在迭代所有V()
。你可以这样做:
g.V().has("prop1", textRegex(".*")).count()
在这种情况下,您可以稍微伪造 Titan,但如果该查询返回大量要迭代的结果,查询仍然可能很慢。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)