Traverse with lightweight edges

I read about lightweight edges and that it allows faster traversal through vertices. I am therefore evaluating whether they make sense for my project. I however did not find any documentation about best practices with these kind of edges.

The most important aspect in my case is the traversal path. I am not using any properties in edges but the @class property for traversal in order to specify which path to follow (to not receive all vertices which are indirectly connected to another but a subset) such as

What would be the counterpart for lightweight edges?

Hi @jonsalvas

As you said, lightweight are an optimization, but they come with a few important trade-offs.

First of all, it’s not possible to query lightweight edges directly. Even worse, if you do a query on an edge class that also “contains” lightweight edges, you will have partial results.

Eg. suppose you have a FriendOf class with a regular edge and a lightweight edge. The following query

SELECT count(*) FROM FriendOf

will return 1, even though the edges are two.

The second problem is that their behaviour can be confusing, as lightweibght edges are automatically converted to regular edges the first time you add a property (and they never go back to lightweight, even if you delete their properties).

Internally, we are planning to implement some optimizations to regular edges, that will make lightweight edges useless in the near future (eg. add links from vertex to vertex automatically, when you create an edge, so that you can completely skip the load of the edge document and have the same performance of lightweight edges)

My suggestion is: if there is real performance reason, ie. you measured it with regular edges and already did all the other optimizations, then you can consider lightweight edges as a last resort, but for the all the other cases you should use regular edges.



1 Like