Re: Benefits of cursors?
Posted in 1994
Ryan L Mcfall (mcfallry@cps.msu.edu) wrote: From mcfallry@cps.msu.edu Fri Jun 10 07:11:15 1994 Return-Path: <mcfallry@cps.msu.edu> Received: from arctic.cps.msu.edu by netcom.netcom.com (8.6.8.1/Netcom) id HAA17531; Fri, 10 Jun 1994 07:11:14 -0700 Received: by arctic.cps.msu.edu (5.0/SMI-SVR4) id AA20291; Fri, 10 Jun 1994 10:10:57 +0500 Date: Fri, 10 Jun 1994 10:10:57 +0500 From: mcfallry@cps.msu.edu (Ryan L Mcfall) Message-Id: <9406101410.AA20291@arctic.cps.msu.edu> To: gburnore@netcom.com Content-Length: 1117 Status: RO : To: gburnore@netcom.com (Gary L. Burnore) : Subject: Re: Benefits of cursors? : Newsgroups: comp.databases.informix : X-Newsreader: TIN [version 1.2 PL0] : Maybe I should restate my original post. I know what the syntax of the : cursor is, allowing you to select multiple rows from a table. : It has been stated the using prepared/declared cursors for select : statements, : __even__ those that would only return one row, are more efficient if the : statement is to be executed more than once. This is what I would like : an explanation of. Is it because the optimizer only has to choose a path : through the indexes once? : Sorry about any confusion No problem. Because you declare the cursor first, this means that the indexes only need to be read once. This would make subsequent fetches (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. -- : /************************************************************** : * Ryan McFall * : * Dept. of Computer Science * : * Michigan State University * : * mcfallry@cps.msu.edu * : * * : * My statments do not reflect the opinions of MSU, * : * Heck, they probably don't even make sense! * : *************************************************************/ -- gburnore@netcom.com ------------------------------------------------------------------------------- How you look depends on where you go. -------------------------------------------------------------------------------