Oracle 中的 Java 存储过程比 PL/SQL 慢吗?
这是一个简单的问题:您知道 Oracle 数据库中的 Java 存储过程是否比 PL/SQL 慢吗?
我们将一个存储过程从 PL/SQL 迁移到 Java 只是为了对其进行基准测试,它花费的时间大约是 PL/SQL 的两倍。这也是你的经历吗?
谢谢。
This is a straightforward question: do you know if Java stored procedures are slower than PL/SQL in a Oracle database?
We've migrated a stored procedure from PL/SQL to Java just to benchmark it and it's taking approximately two times the time of the PL/SQL one. Is this also your experience?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当您在语言之间切换时,都会产生开销,称为上下文切换。
( http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:60122715103602 )
在 SQL 和 PL/ 之间移动甚至会产生开销SQL 和它们的集成非常紧密。因此,在 Java 和 PL/SQL 之间移动的效率始终低于纯 PL/SQL。
Java 存储过程与 PL/SQL 存储过程
至于发生上下文切换后的性能,您的基准测试将为您提供最佳答案,但 FWIW,因为 PL/SQL 与 Oracle 数据库紧密集成如果您正在获取数据或与数据库交互,它应该比存储的Java代码执行得更好,如果您纯粹是操作已经获取的数据,那么这将取决于您对数据所做的操作,并且您的基准测试会告诉您答案。
Whenever you switch between languages you will incur an overhead, called a context switch.
( http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:60122715103602 )
There is even an overhead in moving between SQL and PL/SQL and they are very tightly integrated. Moving between Java and PL/SQL will therefore always be less efficient than pure PL/SQL.
Java Stored Procedure Vs PL/SQL Stored Procedure
As for the performance once the context switching has taken place, your benchmarking will give you the best answer but FWIW, as PL/SQL is so tightly integrated within the Oracle database it should perform better than the stored Java code if you are fetching data or interacting with the DB, if you are purely manipulating already fetched data, it would depend upon what you are then doing to the data and your benchmark will tell you the answer.
是的。 Java 一直是最胖、最慢的孩子。
99% 的工作都没有理由从 pl/sql 切换到 java。
我使用 java 来处理我需要的少数实例。
Yes. Java has always been the fattest, slowest kid on the block.
There's no reason to switch from pl/sql to java for 99% of what you might do.
I use java for the few instances I need to.