Neo4j Bolt中的Session.run()VS transaction.run() [英] Session.run() VS transaction.run() in Neo4j Bolt

查看:983
本文介绍了Neo4j Bolt中的Session.run()VS transaction.run()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Neo4j Bolt驱动程序中的Session.run()和transaction.run()有什么区别?

What is the difference between the Session.run() and transaction.run() in Neo4j Bolt driver?

我的知识是:

Session.run() will execute a single statement    
transaction.run() executes multiple statements.

这些是我所知道的正确信息.其他所有区别是什么?

Those are the information I know which are correct. What are the all other differences?

推荐答案

Session.run()实际上将创建一个事务,执行该语句,然后提交该事务. Transaction.run()将使事务保持打开状态,直到您提交它为止,但是该语句仍将被发送,解释和执行,并返回结果.但是,任何更改实际上都不会持久存储在数据存储中,并且对于事务外部的查询也不可见.您必须将交易标记为成功并提交,否则它将回滚.

Session.run() will actually create a transaction, execute the statement, and commit the transaction. Transaction.run() will leave the transaction open until you commit it, but the statement will still be sent and interpreted and executed, and results will be returned. However, any changes won't actually be persisted into the datastore, and won't be visible to queries outside of the transaction. You have to mark the transaction as successful and commit it or it will be rolled back.

您应该尝试不使用交易;开放式事务可防止更改索引和约束并增加内存使用量.使用事务的唯一原因是具有回滚潜力.如果您想查看查询的结果是什么,并可能根据这些结果将其撤消,请使用事务.否则,请使用会话.

You should try not to use transactions; open transactions prevent changes to indexes and constraints and increase memory usage. The only reason to use transactions is for the rollback potential; if you want to see what the results of the query are, and maybe undo it depending on those results, then use a transaction. Otherwise use a session.

这篇关于Neo4j Bolt中的Session.run()VS transaction.run()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆