View and stored procedure, which one is faster

Would you please tell me which one is faster between view and stored procedure? This is just for returning 1 single record in joined tables in a database

CochiseCountyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
I don't think there will be any noticable difference between the two in such a simple application.  I would recommend using a view.
0
LowfatspreadCommented:
flip a coin and choose one!

..

the view maybe faster since when you pass your query with it it will be compiled by SQL server for the specific
acess path requirements your selection conditions require...

the stored procedure maybe faster ... since after the first execution of it SQL server may no longer have to work
out the optimal access path ,since the execution path maybe cached, however that execution plan may not be
optimal for the particular criteria you have passed to the stored procedure...

..

you are basically trying to compare two different complimentary objects (not totally an apples vs orange , or a Bently vs. Rolls scenario either)

you should use both together appropriatly


you use views to create standard joins / visualisation  for queries and views are another way of being able to
control (for security) access to your data...

you use stored procedures to enable complex SQL operations to be hidden from the user and optimised,
also to provide an encapsulated standard API/method for your data.


in short both should be used...

if the user requires to perfom a function that should be written as a stored procedure (or several)

Common linkages between tables , or access paths , or even where the potential for future change
is recognosed should be wrapped in views (many shops standardly create a BASE view for a tables
and enforce procedure that all access is via views to allow for easier maintenance growth ... )


ad-hoc USER enquires against the database are best performed via views...

hth






   
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.