• ryan.leuty (8/12/2008)


    What's wrong with views?

    They have a tendency to be badly misused, much like cursors, UDFs, et al.

    I've seen lots of views that included six or seven tables, dozens of columns, and the view is referenced in a proc that needs two of the columns, one each from two tables that have a direct FK relationship.

    That kind of thing often kills performance, because it messes up execution plans horribly.

    As with all of these, it's not the uses that are bad, it's the misuses, and the fact that misuses outnumber uses by a huge margin.

    A view that defines a complex, multi-table join that's used in many procs, and thus simplifies the procs, can be very valuable. Index views of common aggregates can be wonderful. Views that are used by lazy database devs who save themselves the thirty seconds it takes to write a join or two, at the cost of killing the performance, those are bad.

    (Just thought of a new sig idea: "Code doesn't kill performance. Bad developers kill performance." The NRA reference might be good enough to run with. 🙂 )

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon