• Sue_H - Wednesday, February 7, 2018 6:45 AM

    subramaniam.chandrasekar - Wednesday, February 7, 2018 12:53 AM

    VastSQL - Wednesday, February 7, 2018 12:48 AM

    Experts,

    We have a procedure which select from a lot of tables. Will there be any performance improvement if we create a view for that select query instead of fetching directly from Table?

    Obviously yes, We'd implemented the same when we wanted to share our data to shared services team.

    I'd be interesting in know how - maybe it's not that obvious.
    It was my understanding that the optimizer doesn't even know it's a view - all that gets to the optimizer is the query that is the definition of the view. So it wouldn't be the optimizer slowing things down. What exactly makes it slower when either the query or the view and it's executing the same thing?

    Sue

    Hi Jeff & Sue,
    Normally In MS SQL Server, query plans are getting stored in execution plan cache for all SQL queries, i.e either normal query or view etc., These queries will get dropped from the cache if they are unused for a long time. Because the unused space will get occupied by new queries and for executions.

    So obviously a view or a sql query will be the same for execution plan cache. I was going to reply the OP to suggest an Indexed view to run the queries faster than a normal table queries.

    Regarding views, Yes I too need a real time example to demonstrate whether view / sql queries will be faster...:ermm::ermm: