SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Which is the faster ?


Which is the faster ?

Author
Message
devu
devu
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 5
Hi all,

I want to know which is the faster group of select statement or stored procedure with same select statements ?

Thanks.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)

Group: General Forum Members
Points: 215694 Visits: 46270
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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)

Group: General Forum Members
Points: 95217 Visits: 33013
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

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)SSC Guru (207K reputation)

Group: General Forum Members
Points: 207326 Visits: 41961
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

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Nadrek
Nadrek
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4350 Visits: 2741
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.
Igor Micev
Igor Micev
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10104 Visits: 5155
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search