Search code examples
indexingneo4jcypher

Neo4j community edition uses AllNodesSan instead of NodeByLabelScan


I am using Neo4j community edition 4.4.11 to build an application.

I have created some Image nodes in my database and performed the following query. I was expecting neo4j to use NodeByLabelScan

PROFILE MATCH (n:Image)  RETURN n LIMIT 25

However, it scanned all database to find Image nodes...

enter image description here

Is this supposed?

Thank you.

can Someone tell me why this happened?


Solution

  • Even with index on :Image, it will do a nodescan because you are not using an index.

    Try this, if you have Image.name that exists.

     create index imageNameIdx for (i:Image) on i.name
    

    Then

     PROFILE MATCH (i:Image) WHERE i.name = <something> RETURN n
    

    It will show you that it is using that index (NodeIndexSeek)