does SQL server query performance depend on the speed of network to the client? -


my test query runs faster when remote desktop connection sql server box, , open management studio there, when connect using management studio remote workstation. question is: why?!

my query not return data back. here's exact text of query:

set quoted_identifier off set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls off set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language us_english set dateformat mdy set datefirst 7 set transaction isolation level read committed    exec dbo.test 

where test defined follows:

create procedure dbo.test begin    declare @cnt int = 0    declare @d datetime    set @d = dateadd(ss,5,getdate());     while getdate() < @d  begin     set @cnt = @cnt + 1    end   print @cnt   end 

both queries take 5 seconds execute, local run returns 7 times bigger value of cnt remote run.

looking @ profiler, lpc protocol used locally, while tcp/ip used remote connection. tried named pipes , slower. thought if query execution not involve returning data client should not depend on network connection or protocol used apparently does.

any ideas why? can validate results?

every time set command called there feedback sent client.

if change code shown below performance lot better (even local). 9 million loops without , 14 million set nocount on. general rule should switch set nocount on first statement of stored procedure.

create procedure dbo.test begin    set nocount on  declare @cnt int = 0    declare @d datetime    set @d = dateadd(ss,5,getdate());     while getdate() < @d  begin     set @cnt = @cnt + 1    end   print @cnt   end 

the set nocount on eliminates sending of done_in_proc messages client each statement in stored procedure. more information done_in_proc can found on msdn


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -