Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 821
  • Last Modified:

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

0
CochiseCounty
Asked:
CochiseCounty
1 Solution
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now