简体   繁体   中英

Is Neo4j faster returning nodes or attributes?

I am working on nodes with several attributes, 7 or 8 attributes per node. Since Neo4j is based on node objects, in case I am interested in getting only one of those attributes, is it faster to return the whole node and then get the attribute, or return directly the attributes? I am talking about queries returning millions of records, and I am using a Java API to gather the results.

If you're talking about the actual return, then returning the node will implicitly return all attributes, so it's going to be more expensive.

If you haven't done the return yet, and are still processing within the transaction, then property access won't happen until you actually access the property or properties yourself.

For either case, Cypher or Java, it's often best to withhold property access until you've done your filtering/limiting/aggregating and just use the node instead, if it makes sense for you to do so. This would avoid performing property access on nodes that may be filtered out due to these operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM