Search code examples
neo4jdatabase-performance

Neo4j: fastest way to find a node: by id function or index?


Is it faster find a node by id function

MATCH (i:Item) WHERE id(i) = 2345 RETURN i

or by a property indexed?

MATCH (i:Item { name: "Foo"}) RETURN i

Profiling these queries I saw

  • id function: 2 total db hits
  • index: 1 total db hits

Solution

  • Find by id is always faster, as it directly points to the node-record.