Performance issue in views for select and join tables

  • Hello friends

     

    We are using lots of views in our application..its a report kind of thing...so there are many select queries with joins in views...so my query is if there is join the should i always use distinct keyword...because we are getting duplicate rows here most of times....

     


    Regards,

    Papillon

  • You shuold NOT use keyword DISTINCT in views unless it's a view for user interface.

    Duplicate rows mean you've got mess in your data. Clean it up.

    _____________
    Code for TallyGenerator

  • Check your joins, it may be that you have unintentional cross joins. Otherwise work out why you have duplicate rows and fix the source of the problem, don't fix the symptoms.

    Distincts are expensive, they force SQL to sort the resultset, requiring temp work tables and all sorts of mess.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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