cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

START WITH performance?

I am designing the graph model at the moment.
I was wondering what is the performance expected for a START WITH query on a indexed String field when there will be a lot of nodes to look in?
Will it be fast enough and use a tree to find the find node I am looking for?

Here is my use-case:
I am trying to model a Folder, File structure system.
I am wondering if I could keep the whole "path" for a File and just drop the Folder entity all-together
That way, I could query all File inside a folder with
Match File Where path Start With "/root/folder"

Thanks

2 REPLIES 2

STARTS WITH will use existing indexes. Those indexes are implemented as trees.

I can't comment on "will it be fast enough" since I don't know your requirements 😉

Maintaining the full path as a property seems like a redundancy since you (well I assume this) have Folder nodes containing other Folder nodes recursively and you have File residing in a Folder. To find anything below a given folder you can use a query like
MATCH (:Folder{name:<whatever>})-[:HAS_CHILD_FOLDER*0..]->(:Folder)-[:CONTAINS_FILE]->(f:File) RETURN f

Thanks @stefan.armbruster!

The folder node/entity will be dropped then. It was just storing a set of File, and is not used except for grouping Files together.
I prefer to have less entities and code to maintain, so to find a set of File under a certain path, I could do:
Match (file:File) Where file.path start with "fullPathNameOfFolder"

Thanks for you input and help with this!