OrientDB:Gremlin Count查询速度极慢

时间:2016-05-16 14:07:52

标签: orientdb gremlin

我试图使用gremlin在OrientDB 2.2中找到计数(用于分页),当我的类有很多顶点(100万)时,这个查询就会死掉(记录计数为startsWith' smi&# 39;过滤器约为6000)。我已经在last_name字段上创建了一个全文(sbtree)。

g.getVerticesOfClass('person')._().filter{it.getProperty("last_name").startsWith("smi")}.count()

我怎样才能更好地写出来,以便在合理的时间内重新计算。我还没有添加排序,因为它给了我outOfMemory。

1 个答案:

答案 0 :(得分:2)

对于使用Gremlin .has()步骤而非使用lambda的本机Groovy .filter()方法,您可能会更幸运。以下可能会更快:

g.getVerticesOfClass('person')._().has('last_name').startsWith('smi').count()

如果你正在使用https://github.com/mpollmeier/orientdb-gremlin,我认为查询优化器还不能使用带有startsWith()谓词的查询的索引。

相关问题