cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Return node instead of node properties. Good or Bad?

mana
Node

Would it be a good idea to return a whole node instead of node properties because of a lower db hits.

PROFILE
MATCH (s:Shape)-[:LOCATED]-(g) 
RETURN g
LIMIT 10

13 total db hits

PROFILE
MATCH (s:Shape)-[:LOCATED]-(g) 
RETURN g.code
LIMIT 10

23 total db hits

1 REPLY 1

When you use PROFILE, you should be aware that it is dependent on whether the query was compiled first as well as the version of the database. A more detailed explanation can be found in this discussion.

Also it is worth asking whether you have an index set up on your nodes? This is an important part of tuning your Cypher query and can greatly reduce DB hits. You can read more about that here and here. But, in general, it is always a good idea in general to return the value of a property rather than the full node/relationships in order to improve performance (more detail here).