• sandhuz24 (10/7/2015)


    Thanks Eirikur!

    Sorry for the delay in getting back to the post. Been really busy at work. I had the indexes on the table as you suggest in your post but I was missing the index on the Row_Num column. You correctly point out that the distinct Sort is taking the longest and hence including the column in the index made the difference.

    For anyone else visiting the post, I should point out that even though the query does not run in under 5 mins, the improvement was considerable - 70% reduction in run time.

    Cheers,

    P.

    You are most welcome and thank you for the feedback

    😎