In my neo4j data, I have unique constraint set.
neo4j-sh (?)$ schema
Indexes
ON :Post(uuid) ONLINE (for uniqueness constraint)
Constraints
ON (post:Post) ASSERT post.uuid IS UNIQUE
However, when i do a profile on query, it seems search is being done by NodeByLabelScan
neo4j-sh (?)$ profile match (p:Post {uuid:"503cb957-9da0-490c-808d-48b64a1b1f64"}) return p;
+---+
| p |
+---+
+---+
0 row
12 ms
Compiler CYPHER 2.2
Planner COST
Filter
|
+NodeByLabelScan
+-----------------+---------------+------+--------+-------------+---------------------------+
| Operator | EstimatedRows | Rows | DbHits | Identifiers | Other |
+-----------------+---------------+------+--------+-------------+---------------------------+
| Filter | 1 | 0 | 2 | p | p.uuid == { AUTOSTRING0} |
| NodeByLabelScan | 1 | 1 | 2 | p | :Post |
+-----------------+---------------+------+--------+-------------+---------------------------+
Total database accesses: 4
Is there something I am missing here?
My neo4j version is 2.2.3.
Neo4j 2.2 introduced a cost based analyzer. I guess here Cypher has the opinion that a NodeByLabelScan with filtering is faster than a index query due to the small number of nodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With