Is there a limit on the number of labels you can put on nodes in Neo4j? Also what are the ramifications of lots of labels on the performance of inserts? Thanks
1 Answer
In theory the number of labels is almost unlimited (not sure but I think it was Integer.MAX_VALUE). In practice you should have as few labels as reasonable on a single node. The first 4-5 (don't remember the exact number) labels are stored directly with the node. The remaining labels are stored in a different location internally. So reading a node having more than 4-5 labels might result in another IO operation.
Upon a write operation every labels will cause extra burden since labels are self-indexing and therefore Neo4j needs to write to the labelscanstore for that label.
Most graphs I've seen so far (and that's quire a few ;-) ) don't have more than 3 labels on a single node.
-
Due to the complexity of our graph we are going to have up to 40 labels per node for certain sections of our graph ( I know this seems crazy, but we won't be able to get round this). Could you point me at any information on where/how the labels are stored for reading? This issue could be really important to us, I knew writing would be an issue, but didn't realize reading would be...– joeSep 1, 2015 at 14:27
-
3The first few labels (5 afaik) directly with the node in the neostore.nodestore.db. In case a node has more labels, they go to neostore.nodestore.db.labels. So for reading a node with lots of labels a second seek operation is needed. This is not a big performance hit, but is has some impact. Sep 2, 2015 at 7:37
-
Hi @StefanArmbruster, I'm wondering if you have any source for the "4-5 labels are stored in the node" figure. I unfrotunately can't find any resource or documentation mentioning these figures– DominusJan 21 at 11:27