January 20, 2014 at 12:15 am
Hi all,
I want to know which is the faster group of select statement or stored procedure with same select statements ?
Thanks.
January 20, 2014 at 12:40 am
Should be the same all other considerations being equal.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 20, 2014 at 5:25 am
To a very large degree, a query is a query. As Gail says, it will be the same. The main thing would be how the query is put together. Let's assume a stored procedure and parameters. Then, do the same query, but with local variables instead of parameters. You may see huge differences there. But it's because the fundamentals of the query changed from using parameters (which can be sniffed) to using variables (which are only sniffed during recompiles).
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 20, 2014 at 4:10 pm
devu (1/20/2014)
Hi all,I want to know which is the faster group of select statement or stored procedure with same select statements ?
Thanks.
My question would be, why don't you just try it and find out for yourself?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 21, 2014 at 8:53 am
Jeff Moden (1/20/2014)
devu (1/20/2014)
Hi all,I want to know which is the faster group of select statement or stored procedure with same select statements ?
Thanks.
My question would be, why don't you just try it and find out for yourself?
+1
Start with Profiler, watching the CPU, Read, Write, and Dur columns, for the SQL:BatchCompleted and RPC:Completed events, filtered on your SPID (session_id) if you're using SSMS, and on your host name and application name and perhaps even some of the text of the query if you're using an app/website/etc.
January 21, 2014 at 11:34 am
Nadrek (1/21/2014)
Jeff Moden (1/20/2014)
devu (1/20/2014)
Hi all,I want to know which is the faster group of select statement or stored procedure with same select statements ?
Thanks.
My question would be, why don't you just try it and find out for yourself?
+1
Start with Profiler, watching the CPU, Read, Write, and Dur columns, for the SQL:BatchCompleted and RPC:Completed events, filtered on your SPID (session_id) if you're using SSMS, and on your host name and application name and perhaps even some of the text of the query if you're using an app/website/etc.
It can be one time better with the select statement, one time better with the stored procedure or the next time equal. As Gail says - same if all considerations being equal.
It matters whether the query causes locking in the system, and if that locking disturbs other operations? In that case with sql procedure you have more options. However consider sniffing parameters with stored procedures.
Regards,
IgorMi
Igor Micev,My blog: www.igormicev.com
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply