Click here to monitor SSC
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-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47261 Visits: 44392
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
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17597 Visits: 32267
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-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45121 Visits: 39921
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Nadrek
Nadrek
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1033 Visits: 2673
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
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4168 Visits: 4849
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,
‌SQL Server developer at Seavus
www.seavus.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