Saim
Saim

Reputation: 15

Optimize the Performance of ROW_NUMBER() OVER (PARTITION BY..)

I am using (SELECT ROW_NUMBER() OVER (PARTITION BY ft.EmpID , dimdt.YEAR_NUMBER, dimdt.MONTH_OF_YEAR_NUMBER ORDER BY dimdt.Date DESC) row_number , field1 .field2 .. ec my ft table has millions of row. I can get the result (month end most recent records of each employee) what I want but it is very slow rather extremely slow. Is there any alternative or a way to optimize the performance?

thanks

Upvotes: 0

Views: 922

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269873

For this expression:

ROW_NUMBER() OVER (PARTITION BY ft.EmpID , dimdt.YEAR_NUMBER, dimdt.MONTH_OF_YEAR_NUMBER ORDER BY dimdt.Date DESC) 

There is not much you can do. The columns are from different tables.

Even phrasing the logic differently would have the same issue -- but you can consider asking a new question with sample data, desired results, and the full query you want to optimize.

Upvotes: 1

Related Questions