Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 which is faster: read_only or fast_forward?

Author  Topic 

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-08-26 : 14:31:27
I'm trying to rewrite a cursor as a select but haven't had much luck. I'm trying to make it faster, so which is faster?

safderalimd
Starting Member

32 Posts

Posted - 2009-08-26 : 15:37:59
My answer doesnt address your question, but here is my opinion on cursors and performance.

99 times out of 100, you can avoid cursors. To me cursor is lazy programmers tool. Did you try using set based SQL operation? If you cant then why not use temp tables in combination with set based SQL.

I do not want to underestimate your skills, maybe your requirement falls in 1 out of 100 where you need cursor bcaz of poor database design.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-26 : 15:38:18
quote:
FAST_FORWARD implies READ_ONLY (although I often include READ_ONLY anyway
for documentation). Personally I always specify LOCAL unless a global
cursor is needed. AFAIK, the fastest server cursor is:

DECLARE MyCursor LOCAL FAST_FORWARD FOR
SELECT ...



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-26 : 15:50:08
>>To me cursor is lazy programmers tool

I think when a developer uses a cursor when a set based option is readily available is not because they are being lazy but rather they are still in the mind-set of a procedural language where set-based operations are simply not available. Besides, an UPDATE or INSERT statement is much simpler to type then to do the same thing with a cursor.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -