Skip to content
Advertisement

Execution plan too expensive case when exists

I have the below query, but when I execute it runs forever.

My execution plan shows a huge cost which I cannot locate. How could I optimize this query? I have tried some hints but none of them have worked 🙁

Kindly let me know if any additional information needed.

Advertisement

Answer

Use window functions:

Not only is the query much simpler to write and read, but it should perform much better too.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement