Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-18-2021 01:08 AM
I'm busy developing an API that needs standard Authentication/Authorization. My users would be identified by their email (as a unique key on the User node). Which approach would be better?
Note: my question has nothing to do with authentication and authorization. Simply around best practice for repetitive queries. In other words: is a query against a node id faster than a query against an indexed field on a node?
The performance concern comes in that this query would have to run for virtually every api request.
Solved! Go to Solution.
10-18-2021 01:43 PM
Lookup via node id is faster than an index lookup.
Be aware that if user nodes can be deleted, then you might not want to use ids, as ids of delete nodes can be reused when creating new nodes, so if you get an id, the node gets deleted, and any other node is created, that id might be reused (and it doesn't have to be a :User node), and now your query is pointing at some completely unexpected node in your graph. If queries using the id are in very close proximity to the query which looks up the id, then you may be fine. You do not want this to cache ids for longer term usage, such as saving them in some alternate database or a longer lived data structure for later querying.
10-18-2021 01:43 PM
Lookup via node id is faster than an index lookup.
Be aware that if user nodes can be deleted, then you might not want to use ids, as ids of delete nodes can be reused when creating new nodes, so if you get an id, the node gets deleted, and any other node is created, that id might be reused (and it doesn't have to be a :User node), and now your query is pointing at some completely unexpected node in your graph. If queries using the id are in very close proximity to the query which looks up the id, then you may be fine. You do not want this to cache ids for longer term usage, such as saving them in some alternate database or a longer lived data structure for later querying.
10-18-2021 10:31 PM
Appreciated thanks
All the sessions of the conference are now available online