Statement是否会影响性能

Statement是否会影响性能

本文介绍了SQL程序中的Print Statement是否会影响性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Server过程,并且习惯于在存储过程中使用Print语句来区分过程代码.

I am using SQL Server procedures and I have a habit of using of Print statements in the stored procedures to differentiate the code of procedure.

我的数据库中有将近200-250个程序.打印声明会影响性能吗?我正在使用多用户Windows应用程序.

I have almost 200-250 procedures in my DB.Should print statement affect the performance?I am working on multi-user Windows application.

推荐答案

在台式机上运行以下内容时,发现打印注释掉了执行时间约15秒,这意味着在我的简单测试中平均影响为15µs. RAISERROR WITH NOWAIT平均增加了两倍多.

I found when running the below on my desktop that commenting out the print knocked about 15 seconds off the execution time meaning the average impact was 15µs in my simple test. RAISERROR WITH NOWAIT added an average of just over double that.

DECLARE @date DATETIME2

DECLARE
  @count INT

SET @count = 1

SET @date = SYSUTCDATETIME()

WHILE @count < 1000000
BEGIN
--RAISERROR ('%d',0,1, @count) WITH NOWAIT
--PRINT @count
  SET @count = @count + 1
END

SELECT DATEDIFF(MICROSECOND, @date, SYSUTCDATETIME()) / 1000000.

这篇关于SQL程序中的Print Statement是否会影响性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:38