Re: Benefits of cursors?
Posted in 1994
Topics: Performance & Tuning
Gary L. Burnore (gburnore@netcom.com) wrote: : David Tomlinson (dtomlnsn@netcom.com) wrote: : : Gary L. Burnore (gburnore@netcom.com) wrote: <clip> : : : : an explanation of. Is it because the optimizer only has to choose a path : : : : through the indexes once? <clip> : I ( gary wrote this) : : : No problem. Because you declare the cursor first, this means that the : : : indexes only need to be read once. This would make subsequent fetches ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Gary, this is what prompted my response. I should have been more succinct. The previous poster's statement that the *path* is chosen only once is accurate. : : : (aka selects) faster. I don't know if/why it would be faster for one : : : instance. I'd venture to say that the difference in performance for one : : : row wouldn't be noticible. If I know for _sure_ that I'll only get one : : : row, I just use a select. If someone has a good reason to always use the : : : declared cursor I'd like to know. : You (David) wrote this. : : No. SQL needs to be pre-processed before the query is ever executed. <clip> : : This, of course, makes subsequent cycles more efficient. <clip> : I'snt what you wrote and what I wrote the same thing? (declared : cursors only pre-proceessed once) I wrote in response to what I perceived as an inaccuracy in your posting and the expression of incomplete understanding of what a cursor actually does by the previous poster. Except for the statement about indexes, your posting was substantially correct. DCT -- @ David Tomlinson @ @ dtomlnsn@netcom.com @ @ "By day fantastic birds flew through the petrified forest, and @ @ jeweled crocodiles glittered like heraldic salamanders on the @ @ banks of the crystalline river. By night the illuminated man @ @ raced among the trees, his arms like golden cartwheels, his @ @ head like a spectral crown...." @