View and stored procedure, which one is faster

Posted on 2006-04-03
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

Question by:CochiseCounty
    LVL 34

    Expert Comment

    by:Brian Crowe
    I don't think there will be any noticable difference between the two in such a simple application.  I would recommend using a view.
    LVL 50

    Accepted Solution

    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...



    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    In this article—a derivative of my blog post (—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Viewers will learn how the fundamental information of how to create a table.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now