About using @rid in the MATCH syntax

Hi all,

How can I use @rid in the MATCH syntax? I have tried the following script, but found that it does not fetch records from RIDs directly according to the explain plan:

image image

Hi,
the equivalent version of
match{class: patient, where: (@rid = "#39:0")} return $paths
without the match statement is:
select from patient where @rid = "#39:0"
if you compare the explains of these two their are approximately the same.

With Match:
image

Without Match:
image

Hope it helps.

Regards,
Michela

I know this, but with SELECT syntax, I can use “select from @rid” to directly fetch records from rid, and I want to know if there is any equivalent version, because in some situation I need to traverse from some vertexes using MATCH syntax, and fetching the vertexes directly from rid is more effiently.

I’ve got the same question and came to an obvious solution

The difference
“Select from »some rid«” returns the database-class.

Using "match{ class: »some class«, where (@rid = »some rid«} " you have to specify the class.

As the query always starts with a vertex, one can substitute this with

 match{ class: V, where (@rid = »some rid«}

Question remains: why is it not possible just to specify

 match{ #39:0  } -> { ....

I want to revive this topic

Queried the following statements

match {class: V, where: ( @rid = #84:129 )} -hc_grid-> { as: a, while: (true) } return a

Explain:

   $ORIENT_DEFAULT_ALIAS_0
  AS
  + FETCH FROM CLASS V
    + FETCH FROM CLUSTER 9 ASC+
  ( many more "fetch statements")
    #  FETCH FROM CLUSTER 336 ASC
    + FETCH NEW RECORDS FROM CURRENT TRANSACTION SCOPE (if any)
  + FILTER ITEMS WHERE 
    @rid = #84:129
+ MATCH      ---->
  {$ORIENT_DEFAULT_ALIAS_0}.out("hc_grid"){a}
+ CALCULATE PROJECTIONS
  a

The query took 0.275 sec

Then

match {class: hc_portfolio, where: ( @rid = #84:129 )} -hc_grid-> { as: a, while: (true) } return a

The »FETCH FOM CLUSER« lines ar narrowed to 8

the query took 0.27 sec

But

select from ( traverse outE('hc_grid').in from #84:129 while true ) where $depth >= 0
+ FETCH FROM SUBQUERY 
  + FETCH FROM RIDs
    [#84:129]
  + DEPTH-FIRST TRAVERSE 
    [outE('hc_grid').in]
  WHILE true
+ FILTER ITEMS WHERE 
  $depth >= 0

takes a different path and takes only 0.24 sec

Seems to me, that match statements are not always preferable.