[英]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
. 我目前有两个名为
community
和user
顶点集合。 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._id
和user._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.