• Jeff Moden (11/14/2016)


    vs.satheesh (8/3/2016)


    Some time I am getting timeout error.

    That's likely the real problem. Such timeouts are normally because of code that has accidental many-to-many joins and folks trying to "do it all" in a single query. "Set based" code doesn't require everything to be done in a single query with a bazillion joins. "Divide'n'Conquer", "DRY" methods, and inline pre-aggregation usually negate the need for building aggregate tables that go out of date as soon as they're populated.

    Often accidental very wide joins are caused by over-use of views, where the poor sucker using a view is a victim of someone else's bad design rather. While 3 way joins are reasonable, if you have a 5-deep nest of views each doing a three-way join the resulting structure at run time may be a 243-way join, if it is that is terrible design and the person who invented that horrible nest is utterly incompetent and I have sympathy for his victims (often the victimes are developers who are told by the "expert dba" responsible for the mess that they have to use the views provided). When a too-wide join is done deliberately be someone trying to "do it all" in one query that's not really "accidental", describing it as "stupid" would be nearer the mark.

    Tom