在orientDB中查找两个给定顶点之间边的最快方法是什么

在orientDB中查找两个给定顶点之间边的最快方法是什么,orientdb,query-performance,orient-sql,Orientdb,Query Performance,Orient Sql,我目前有两个顶点集合,分别名为community和user。 作为社区成员的每个用户都使用edgecommunity\u user链接到该社区 我正在尝试更新给定用户的community\u用户edge及其id SELECT read from community_user where outV() in (select @rid FROM `community` WHERE ( `_id` = '5ab283c35b6b9435d4c9a958' )) and

我目前有两个顶点集合,分别名为
community
user
。 作为社区成员的每个用户都使用edge
community\u user
链接到该社区

我正在尝试更新给定用户的
community\u用户
edge及其id

SELECT read from community_user where 
     outV() in (select @rid FROM `community` WHERE ( `_id` = '5ab283c35b6b9435d4c9a958' )) 
     and 
     inV() in (select @rid from user where _id  = 'x5mxEBwhMfiLSQHaK')
此查询确实有效,但一旦
community\u用户
edge被填充,查询速度会相当慢

有没有办法索引此搜索或更快的解决方案来找到我需要的值

我当前的相关索引位于
社区。_id
用户。_id

该查询的
EXPLAIN
结果为:

{
    "result": [
        {
            "@type": "d",
            "@version": 0,
            "documentReads": 1,
            "fullySortedByIndex": false,
            "documentAnalyzedCompatibleClass": 1,
            "recordReads": 1,
            "fetchingFromTargetElapsed": 0,
            "indexIsUsedInOrderBy": false,
            "currentMatch": null,
            "compositeIndexUsed": 1,
            "current": "#169:839",
            "depth": 0,
            "involvedIndexes": [
                "user._id"
            ],
            "limit": -1,
            "matched": {
                "$ORIENT_DEFAULT_ALIAS_0": "#1770:0",
                "theEdge": "#1817:1889"
            },
            "evaluated": 1,
            "elapsed": 1490.7661,
            "resultType": "collection",
            "resultSize": 1,
            "@fieldTypes": "documentReads=l,documentAnalyzedCompatibleClass=l,recordReads=l,fetchingFromTargetElapsed=l,compositeIndexUsed=l,current=x,involvedIndexes=e,evaluated=l,elapsed=f"
        }
    ],
    "notification": "Query executed in 1.521 sec. Returned 1 record(s)"
}

最简单的方法是使用MATCH语句

MATCH
  {class:community, where:(_id = '5ab283c35b6b9435d4c9a958' )}
    .outE(){as:theEdge}.inV(){class:user, where:(_id  = 'x5mxEBwhMfiLSQHaK')}
RETURN $elements

我尝试了这个查询,它比我之前的查询更慢。我的执行时间为+-600毫秒,而你的执行时间约为1.5秒。如果这对您有帮助的话,我将添加一个查询解释。您的查询确实将读取的记录限制为1,尽管速度仍然很糟糕。