Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-28-2019 02:48 PM
When MATCH'ing on a single value the documentation is comprehensive and also suggests that:
MATCH (cid:Cid {contentID: '5ef78674-7631-11e4-a3cb-005056011aef')
RETURN cid
;
is faster / more efficient than
MATCH (cid:Cid)
WHERE cid.contentID = '5ef78674-7631-11e4-a3cb-005056011aef'
RETURN cid
;
What's the faster approach to inspecting many nodes for specific values, as in the query below? (each contentID is unique (constrained))
MATCH (cid:Cid)
WHERE cid.contentID IN ['5ef78674-7631-11e4-a3cb-005056011aef','5ef79922-7631-11e4-a3cb-005056011aef']
RETURN cid
;
07-28-2019 05:04 PM
There is no performance difference between the query with the property inline in the pattern vs in the WHERE clause. They should both generate the exact same query plan.
Your existing query using property membership IN a list is the right way to go. The only thing to recommend is that you have an index or unique constraint (whichever is appropriate) on :Cid(contentID)
07-29-2019 08:32 AM
Thanks for clarifying, Cid.contentID
currently has a unique constraint. How do I decide whether a index or unique constraint is the preferred approach?
07-29-2019 08:36 AM
If the property is meant to be unique across all nodes of that label, then use a unique constraint (it will create an accompanying index for you automatically). If it's not unique but you'll be using it for frequent lookups of nodes of that label (like :Person nodes with a name
property) then use an index.
12-27-2022 04:08 AM
ef78674-7631-11e4-a3cb-005056011aef what is this ? please explain
12-27-2022 05:17 AM
Can you please explain your question? I don’t understand.
All the sessions of the conference are now available online