Distinct & groupby

  • Hi,

    I am working with SP. I have to tune that sp.

    I do have similar kind of code in two of the sp. I changed the distinct to group by. I found that 200-300msec in one sproc but in the other sproc same code I change same but there is no difference.

    I am not able to understand.

    It is using the same tables and same data we are retrieving.

  • You should really stop believing in myths. Group by and Distinct are designed for different cases. When you're grouping use group by and when you want to eliminate duplicates use distinct. Performance is not a reason to change from one to another.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • ramana3327 (6/2/2014)


    Hi,

    I am working with SP. I have to tune that sp.

    I do have similar kind of code in two of the sp. I changed the distinct to group by. I found that 200-300msec in one sproc but in the other sproc same code I change same but there is no difference.

    I am not able to understand.

    It is using the same tables and same data we are retrieving.

    Without table/index DDL and actual execution plan, there's not much we can say here.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

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

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