We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

View and stored procedure, which one is faster

CochiseCounty
on
Medium Priority
854 Views
Last Modified: 2010-05-18
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

Comment
Watch Question

Brian CroweDatabase Engineer
CERTIFIED EXPERT
Top Expert 2005

Commented:
I don't think there will be any noticable difference between the two in such a simple application.  I would recommend using a view.
CERTIFIED EXPERT
Top Expert 2011
Commented:
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






   

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.