Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to increase performance of ROW_NUMBER() OVER (PARTITION BY..) in Sql Server 2016

Status
Not open for further replies.

BTrees

IS-IT--Management
Aug 12, 2006
45
CA
Hello Every one,

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
 
Give us
[ul]
[li]Full code[/li]
[li]DDL for all tables involved[/li]
[li]Actual Explain plan[/li]
[/ul]

[ul]
[li]Underlying Windows Server spec - cpu/mem[/li]
[li]SQL Server max memory, max dop and "cost Threshold for parallelism" values[/li]
[/ul]

And we may be able to help you.

and exactly what is your intention - is it the most recent entry you need? latest 10? without knowing the requirements we can't help either - and do take in consideration that code alone without any explanation won't be any good.

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Thanks fred. Due to privacy policy , I can not share original code publicly. Is there any way to share privately?

Thanks
 
Hi Fred, I have sent you the information. Hope the address would be ok. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top