Views or Sub Queries?

  • Hi,

    Does anyone know performance wise, which better a view or a subquery?

    Cheers

    Reet

  • Views and Subqueries cannot be really compared, Views are compared to stored procs and Subqueries are compared to JOINs or UNION.  JOINs are the same in performance to Subqueries and in ANSI SQL Subqueries are updatable while JOINs are not but T-SQL let you update JOINs.  Now to your questions if you are in SQL Server 2005 lookup CTE(common table expressions) they are in memory Views so faster than the persisted Views and more like compiled stored procs.  The reason in ANSI SQL Views are query rewrites just persisted while Subquery do the same thing as a JOIN but are updatable.  Hope this helps.

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply