为什么或()查询未在Datastax DSE 5.0.x Graph中使用索引?
问题描述:
我已经创建用户和UUID的为什么或()查询未在Datastax DSE 5.0.x Graph中使用索引?
的指数,如果我做的:
schema.vertexLabel("User").describe()
我得到:
schema.vertexLabel("User").index("byUuid").materialized().by("uuid").add()
当我运行:
g.V().hasLabel("User").has("uuid","oneUuid")
的索引正确拾取..
但是当我做到以下几点:
g.V().or(__.hasLabel("User").has("uuid","oneUuid"), __.hasLabel("User").has("uuid","anotherUUID"))
我越来越:
org.apache.tinkerpop.gremlin.driver.exception.ResponseException:难道 没有找到一个索引来回答查询子句和graph.allow_scan是 已禁用:
谢谢!
答
or()
不容易优化的,你可以做更复杂的东西,如:
g.V().or(
hasLabel("User").has("uuid","oneUuid"),
hasLabel("User").has("name","bob"))
...其中一个或多个条件无法通过索引查找来回答。这是可行的,并可能在未来的版本中完成,但afaik目前可用的图形数据库都没有试图优化OrStep
。
总之,您的样本查询可以很容易地被改写,使其实际使用该索引:
g.V().hasLabel("User").has("uuid", within("oneUuid", "anotherUUID"))
谢谢!我知道内部(),但我期待我的具体或()情况转换为您发送的。 –