locked
Reviewing nested views - SQL Server 2012 RRS feed

  • Question

  • Hi,

    generally I don't like to use a view for a performance question.

    However, ultimately I'm analyzing a db in a prod environment having some nested views, that is a view uses another view and so on. I think to rewrite some of these in order to have, if possible, an unique view and not a view that uses another view and so on.

    Is it the right approach?

    Thanks

    Tuesday, November 12, 2013 1:12 PM

Answers

  • However, ultimately I'm analyzing a db in a prod environment having some nested views, that is a view uses another view and so on. I think to rewrite some of these in order to have, if possible, an unique view and not a view that uses another view and so on.

    Yes, avoiding view nesting is a good approach.  Of course, index tuning may also be in order.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    Tuesday, November 12, 2013 1:19 PM

All replies

  • However, ultimately I'm analyzing a db in a prod environment having some nested views, that is a view uses another view and so on. I think to rewrite some of these in order to have, if possible, an unique view and not a view that uses another view and so on.

    Yes, avoiding view nesting is a good approach.  Of course, index tuning may also be in order.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    Tuesday, November 12, 2013 1:19 PM
  • Hi,

    It's possible but you have to put simplicity vs performance in balance.

    What would you prefer?

    A 300 lines view with an extremely complex definition? 

    Or 5 smaller and easier to maintain views? (at the cost of slower performance)

    There's no straightforward response, it all depends on your particular business needs.


    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu

    • Proposed as answer by Allen Li - MSFT Thursday, November 14, 2013 2:18 AM
    Tuesday, November 12, 2013 2:00 PM