OrientDB Traverse SQL query efficiency

Apologies I am new to Graphing DB! I have the following basic structure in an OrientDB:

enter image description here

I need to obtain all the permission associated with a given User. permission are always contained in a Role but a Role can belong either directly to a User or to a Team. I haven’t added it to the image but the edges between User > Role and Team > Role are has. And between User > Team are member.

My current approach is:

SELECT permission FROM ( TRAVERSE out() FROM User ) WHERE $depth <= 2

However, I suspect that there is a much more efficient was of achieving this.

Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.