Skip to content

Graph modeling

Graph data modeling suggestions

This section provides general suggestions for modeling data in Nebula Graph.

Note

The following suggestions may not apply to some special scenarios. In these cases, find help in the Nebula Graph community.

Model for performance

There is no perfect method to model in Nebula Graph. Graph modeling depends on the questions that you want to know from the data. Your data drives your graph model. Graph data modeling is intuitive and convenient. Create your data model based on your business model. Test your model and gradually optimize it to fit your business. To get better performance, you can change or re-design your model multiple times.

Edges as properties

Traversal depth decreases the traversal performance. To decrease the traversal depth, use vertex properties instead of edges.

For example, to model a graph that have the name, age, and eye color elements, you can:

  • (RECOMMENDED) Create a tag person, then add the name, age, and eye color as its properties.
  • (WRONG WAY) Create a new tag eye color and a new edge type has, then create an edge to indicate that a person has an eye color.

The first modeling solution leads to much better performance. DO NOT use the second solution unless you have to.

Multiple properties under one tag are permitted. But make sure that tags are fine-grained. For more information, see the Granulated vertices section.

Granulated vertices

In graph modeling, use the data models with a higher level of granularity. Put a set of parallel properties into one tag, i.e., separate different concepts.

Use indexes correctly

Correct use of indexes speeds up queries, but indexes reduce the write performance by 90% or more. ONLY use indexes when you locate vertices or edges by their properties.

No long string properties on edges

Be careful when you create long string properties for edges. Nebula Graph supports storing such properties on edges. But note that these properties are stored both in the outgoing edges and the incoming edges. Thus be careful with the write amplification.


Last update: May 20, 2021
Back to top