Reputation: 800
I currently have 2 vertex collections named community
and user
.
Each user whom is member of a community is linked to that community using the edge community_user
.
I am trying to update a community_user
edge for a given user their _id and a given community
its _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')
This query does work, although it is rather slow once the community_user
edge is getting filled.
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
The EXPLAIN
of that query results in:
{
"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)"
}
Upvotes: 0
Views: 75
Reputation: 2814
The easiest way is using a MATCH statement
MATCH
{class:community, where:(_id = '5ab283c35b6b9435d4c9a958' )}
.outE(){as:theEdge}.inV(){class:user, where:(_id = 'x5mxEBwhMfiLSQHaK')}
RETURN $elements
Upvotes: 0