为什么 SQL Developer 与 SQL Plus 中的 Oracle PL/SQL 响应时间存在差异?
我有 PL/SQL 函数,它返回包含 28 列和 8100 行的游标。当我从 SQL Plus 执行该函数时,我立即得到结果,而在 SQL Developer 中,我运行的脚本需要很长时间(大约 80 秒)。 Java 代码也会发生同样的情况。当列数减少到 2 时,我在不到 4 秒的时间内得到了响应。有人可以解释一下这种情况是怎么回事吗?
I have PL/SQL function that returns cursor that holds 28 columns and 8100 rows. When I execute that function from SQL Plus I got the results right away and in SQL Developer I'm running script that takes looong time (about 80 seconds). The same happen from Java code. When number of columns reduced to 2 then I got response in less than 4 seconds. Can someone explain what is going on in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的实验是更改 SQL Developer 中的“SQL 数组获取大小”,默认值为 50。如果您看到将其更改为 500 的结果,那就是答案。
有趣的是,等效的 SQLPlus 参数的默认值仅为 15,但正如 APC 所说,SQLPlus 具有原生的优势。
如果更改“SQL Array Fetch Size”没有任何作用,那么接下来要注意的是 JDBC 设置,SQL Developer 使用该设置,而 SQL*Plus 则不使用。
The easiest experiment to make is changing the "SQL Array Fetch Size" in SQL Developer, which defaults to 50. If you see results from bumping it to 500, there's the answer.
Interestingly, the default for the equivalent SQLPlus parameter is only 15, but as APC said, SQLPlus has the advantage of being native.
If changing "SQL Array Fetch Size" does not do anything, the next thing to look at is JDBC settings, which SQL Developer uses and SQL*Plus does not.
除了我之前的好答案之外...
一旦返回第一行,SQL*PLus 就会将数据直接发送回屏幕,而 SQL Developer 必须在显示记录之前找到要返回的结果集的大小。
这可以解释为什么 SQL Developer 会出现延迟,尤其是在结果集很大或需要很长时间才能完全返回时(例如,如果执行路径很复杂)。
In addition to the good answers before mine...
SQL*PLus sends the data straight back to the screen as soon as the first rows are returned whereas SQL Developer has to find the size of the resultset to return in advance of displaying records.
This might explain why there is a delay for SQL Developer especially if the resultset is large or takes a long time to fully return (e.g. if the execution path is complicated).