dbms_output.put_line
dbms_output.put_line
是否会降低 plsql
代码的性能?
Does dbms_output.put_line
decrease the performance in plsql
code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
dbms_output.put_line
是否会降低 plsql
代码的性能?
Does dbms_output.put_line
decrease the performance in plsql
code?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
每多一行代码都会降低代码的性能。毕竟是多一条要执行的指令,至少会消耗一些CPU。所以是的,dbms_output.put_line 会降低性能。
真正的问题是:这行额外代码的好处是否超过了性能损失?只有你能回答这个问题。
问候,
抢。
Every extra line of code decreases the performance of code. After all, it is an extra instruction to be executed, which at least consumes some CPU. So yes, dbms_output.put_line decreases the performance.
The real question is: does the benefit of this extra line of code outweigh the performance penalty? Only you can answer that question.
Regards,
Rob.
是的,这是另一段需要执行的代码,但除非实际打开输出,否则我认为开销是相当小的。
这是一个包含更多详细信息的 AskTom 问题: 包中保留的 dbms_output.put_line 语句对性能有影响吗?
Yes, it's another piece of code that needs to be executed, but unless the output is actually turned on, I think the overhead is quite minimal.
Here's an AskTom question with more details: Is there a performance impact for dbms_output.put_line statements left in packages?
您可以查看条件编译,以便DBMS_OUTPUT.PUT_LINE仅在如果过程是使用适当的选项编译的,则为预解析的代码。
一个问题是,DBMS_OUTPUT.ENABLE 是否被调用。
如果是这样,DBMS_OUTPUT.PUT_LINE 中的任何值都将记录在会话的内存结构中。如果您继续将内容推入其中而不将其取出(某些应用程序服务器连接可能会出现这种情况),您可能会发现几天后内存中有很多内容。
You can look into conditional compilation so that the DBMS_OUTPUT.PUT_LINE are only in the pre-parsed code if the procedure is compiled with the appropriate option.
One question is, has DBMS_OUTPUT.ENABLE been called.
If so, any value in a DBMS_OUTPUT.PUT_LINE will be recorded in the session's memory structure. If you continue pushing stuff in there and never taking it out (which might be the case with some application server connections) you might find that after a few days you have a LOT of stuff in memory.
我使用日志表而不是 dbms_output。确保设置为自治事务,例如(当然根据您的需要进行修改):
当然,请确保创建日志表。在您的代码中,如果您在循环中执行许多操作,您可能只想在每个 x num 操作中记录一次,例如:
请注意,自治事务将确保插入您的日志 stmt,即使发生错误并且您回滚其他所有内容(因为它是一个单独的事务)。
希望这有帮助...比 dbms_output 好得多;)
I use a log table instead of dbms_output. Make sure to setup as autonomous transaction, something like (modify for your needs of course):
Make sure you create your log table of course. In your code, if you're doing many operations in a loop, you may want to only log once per x num operations, something like:
Note that the autonomous transaction will ensure that your log stmt gets inserted, even if an error occurs and you rollback everything else (since its a separate transaction).
Hope this helps...much better than dbms_output ;)
这取决于您调用 dbms_output.put_line 的次数与您在 PL/SQL 中执行的其他操作的比率。
It depends on the ratio of how many times you call
dbms_output.put_line
versus what else you do in PL/SQL.使用 DMBS_OUTPUT 也可能是导致以下错误的原因:
ORA-04036: 实例使用的 PGA 内存超出 PGA_AGGREGATE_LIMIT
Using DMBS_OUTPUT might also be the cause of the following error:
ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT