I need help to improve the performance of this view

Amey 2017-11-13 16:29:53

This view returns around 380K rows and it takes around 2 minutes. There is not really a baseline to tell ,if it is slow or fast , but the goal is the improve its performance. The only tweak I did is the replacement of ' distinct' with 'Group bys'. Any pointers towards tweaking this query will be helpful.

Aaron Bertrand 2017-11-30 17:48:58
Returns 380K rows to where? An SSMS grid? Does it make sense to return 380K rows to anything? You might consider not returning all 380K rows anywhere and instead implement paging – 100 or 1000 rows at a time. It's possible your perception of "slow" is because it takes 2 minutes to return all the data across the network and render it in some grid, not because the query is slow or there is anything wrong with the view.