Which type uses more space on disk in Neo4J: boolean or int 0/1?

Viewed 20

I am just wondering about the size of data types on disk.

We need a flag for (potentially) a lot of nodes, it is a boolean (0|1) flag. So I would use a short key.

Should I use boolean (true|false) or numeric (1|0) value for this in order to save space on disc?

This page is crucial for this topic, but is does not say much regarding used space, bits and bytes:

The property types:

  • Number, an abstract type, which has the subtypes Integer and Float
  • String
  • Boolean

Java Driver

I can get int, long, number and boolean by using the Java Driver. But I have no clue, which one is indicated in which case and what they mean exactly regarding their size.

1 Answers

Generally speaking what we call a boolean (true/false) will be then stored with a single bit, meanwhile an integer can vary in size, but often the "normal" int value takes 32bit.

So, if you just need to have a property as a flag I highly suggest to use the Boolean type.

If you want to lean more also take a look at this Neo4j doc page, it might helps

Related