Skip to main content
Loading
Version: Graph 2.0.0

Handling Supernodes

What is a supernode?

A supernode is a vertex with a disproportionately high number of incoming or outgoing edges. Since supernodes are connected to so many other vertices in the graph, traversing supernodes may lead to performance problems due to their highly interconnected nature. The existence of supernodes and, more importantly, traversing over supernodes should be a conscious decision when modeling your data.

Designating supernodes

Aerospike Graph makes a clear distinction between regular vertices and supernodes. Regular vertices maintain inline record edge lists (adjacency lists) to optimize database lookups and thereby improve query performance. Supernodes are maintained in multi-record edge lists that allow for lazy composition of edges as needed for traversal. As a general rule, Aerospike Graph treats any vertex with more than 8,000 edges as a supernode.

The ~supernode flag is a virtual property that can be used to denote that a vertex is or will become a supernode. This is useful for when you know that a vertex will be a supernode, so that AGS doesn't spend time and resources populating the record edge lists for a vertex which can't optimally use it.

Example

The following examples demonstrates how to set the ~supernode flag on a newly created vertex:

Vertex v = g.addV("test").next();
g.V(v.id()).property("~supernode", true).iterate();

The vertex test in the above example is internally marked as a supernode and the record edge list is ignored.

Considerations

  • Once the ~supernode flag is set, it cannot be unset. It remains in place for the duration of the life of the vertex.

  • You cannot read the value of the ~supernode flag. If you read it back, it returns nothing.

  • The value you assign to the flag doesn't matter. Any value assigned to the ~supernode flag is treated as true.