Fastest way to check if a RID is from a Vertex or an Edge

36 views
Skip to first unread message

André Toscano

unread,
Sep 13, 2016, 9:06:35 AM9/13/16
to orient-...@googlegroups.com
Hi guys, since now I was just watching the discussions.
I have I doubt that: What is the fastest way to ensure that a RID is from a vertex or an edge?
I was doing:

select from V where @rid = #<some_rid>

If I get the record it will be a vertex. This is a very expensive query, almost 2s in my system.
This is much faster:

select from #<some_rid> where @class = 'V' or @class in (SELECT name from (select expand(classes) from metadata:schema) where 'V' in superClasses)
 
This is executed in 40ms
But if I ask directly for the RID:

select from #<some_rid>

It takes 10 to 20ms

My ask is if there is a faster way (below of 40ms) to check the RID object type.
Best regards 
André Emilio Toscano

Ivan Mainetti

unread,
Sep 13, 2016, 9:16:30 AM9/13/16
to orient-...@googlegroups.com
Hi,
use this 
select from <rid> where @this instanceof 'V'  --> to verify whether it's a Vertex
select from <rid> where @this instanceof '
E'  --> to verify whether it's an Edge

André Toscano

unread,
Sep 13, 2016, 2:16:06 PM9/13/16
to OrientDB
Perfect Ivan, this query executes in 10 to 20ms.
Thank you very much.
Best regards
André
Reply all
Reply to author
Forward
0 new messages