[Neo] Performance/storage considerations - best practice question

Johan Svensson johan at neotechnology.com
Fri Jan 29 15:10:38 CET 2010


Hi,

On Wed, Jan 27, 2010 at 11:15 PM, Rick Bullotta
<rick.bullotta at burningskysoftware.com> wrote:
> Is there any recommendation on when to use additional node/relationship
> connections versus additional node properties?

It depends of use case but go with relationships if it "enriches" the
graph with information that makes sense.

In your case it sounds like you will not modify the hashmap data and
only read it once so the best way here would probably be to store it
as a blob (array property).  If your use case included modifying the
hashmap often and performing traversals (or matching graph patterns)
filtering out nodes depending on the properties of the hashmap you
should use relationships.

The cost of a relationship operation vs a property operation will
depend on the property but for primitive types (that can fit in 8
bytes) a property add is a little faster than a relationship create.
Adding a string or an array will however be slower than a single
relationship create.

-Johan

>
>
>
> Specifically, I have a need to serialize/save a well-defined data structure
> to Neo.
>
>
>
> Imagine I have a Java class.  That class has some properties, A, B, C.  A
> and B are primitives, and C is a String-keyed hashmap of complex types that
> each have five properties, all of which are primitives, that we'll call
> P1,P2,P3,P4 and P5.  Assume there are 10 items in this collection, with keys
> X1,X2.X10.  These values will generally be read only once at application
> startup, and written very infrequently.
>
>
>
> Option #1: Create a node, store A and B as properties on that node.  Create
> a node for each object in the hashmap, with a relationship to the previously
> created node, and set properties on this node corresponding to the key and
> each of the properties.
>
>
>
> Option #2:  Create a node, store A and B as properties on the node, and
> store the rest of the data as properties using a naming pattern such as:
> C.X1.P1, C.X1.P2...C.X10.P5
>
>
>
> I guess the core question is, what is the relative cost of storing
> additional properties and some light parsing versus storing additional
> relationships and nodes?
>
>
>
> Option #1 is obviously much more "pure", but at what cost?
>
>
>
> Thanks,
>
>
>
> Rick


More information about the User mailing list