简体   繁体   English

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

[英]What is the fastest way to find an edge between two given vertexes in orientDB

I currently have 2 vertex collections named community and user . 我目前有两个名为communityuser顶点集合。 Each user whom is member of a community is linked to that community using the edge community_user . 社区成员中的每个用户都使用edge community_user链接到该community_user

I am trying to update a community_user edge for a given user their _id and a given community its _id. 我正在尝试为给定用户的_id和给定community的_id更新community_user边缘。

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')

This query does work, although it is rather slow once the community_user edge is getting filled. 此查询确实有效,尽管一旦填充了community_user边缘时它会相当慢。

Is there a way to index this search or faster solution to find the value I need? 有没有办法索引此搜索或更快的解决方案来找到我需要的值?

My current relevant indexes are on community._id and user._id 我当前的相关索引位于community._iduser._id

The EXPLAIN of that query results in: 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)"
}

The easiest way is using a MATCH statement 最简单的方法是使用MATCH语句

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM