Cursors Without Performance Penalties

,

One of the very common ways that many developers learn to write code is through loops. Almost every language as some sort of FOR and WHILE looping structure. Many people build these in T-SQL, which often creates performance issues as the engine inefficiently deals with the RBAR (row by agonizing row) processing.

That seems like it might change in the next version of SQL Server. There is an interesting research paper from the SQL Server team that explains how they are investigating a technique that will make decode the inner workings of any code that is inside a cursor and apply the work efficiently to any table operations. If this actually turns out to be true, then cursors in T-SQL might be like cursors in PL/SQL, where this is the preferred way to write code.

Suddenly cursors will have no real performance penalty. If that's the case, I suspect we'll start to see lots of new refactored code in many organizations. Loops make sense and are easy to read. I don't know that I'd change any existing code, but I'd consider changing new code. Do you feel the same way? I wonder how many of you would prefer writing loop based code as opposed to complex single statement SELECTs.

I'm not sure when we'll actually change our habits, and you probably agree if you clicked the link. Today is April 1, or April Fool's Day, so this whole thing is completely fabricated. Hopefully you smiled and this helps you cope with the day a little better.

Rate

5 (3)

Share

Share

Rate

5 (3)