Reputation: 1035
If we want to find a person details using the personName
in neo4j
, we need go through all the nodes
that are with label
person
. But in relational database
we can do it just by going to the person table
and finds the record. So, how this searching works in neo4j
? I mean
1) Is it first finds all the nodes with label
person
and than searches in those nodes
to match with the personName
OR
2) Searches every node
on the way it encounters, than if the label
is person
than checks for personName
. If not matches than goes to another node
and so on..
Upvotes: 2
Views: 89
Reputation: 39915
If there is a schema index on label :Person
and property personName
(CREATE INDEX ON :Person(personName)
) the following cypher statement will be a done by a simple index lookup:
MATCH (n:Person{personName:'John'}) RETURN n
If the index does not exist, Neo4j will iterate over all nodes having the Person
label and filter them by their property (which is somehow comparable to a full table scan in relational world).
Upvotes: 5