Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: loop

Re: loop

From: Karen Abgarian <abvk_at_ureach.com>
Date: Wed, 07 Aug 2002 04:52:16 GMT
Message-ID: <3D4F55D8.9800FF92@ureach.com>


You are right, second fetch is not done.

However, Oracle still keeps reading to check too-many-rows condition. You can see that in reads in the trace output. This means that the second piece of code will inevitably be slower, so the classic who wrote this was right in the performance part.

I do not remember where I read this. I am sorry about that. I could find it on my bookshelf but I do not have time. Maybe I find it some day and post the name of the author.

Regards
AK

Connor McDonald wrote:

> Karen Abgarian wrote:
> >
> > > You'll find a lot of people saying that explicity declaring cursors is
> > > faster than not, ie they will claim that
> > >
> > > cursor X is select ...
> > > open
> > > fetch
> > > close
> > >
> > > is faster then
> > >
> > > select ..
> > > into variable
> > > from table
> > >
> > > Ask them to prove it...they'll struggle :-)
> > >
> > > hth
> > > connor
> > > --
> > > ==============================
> > > Connor McDonald
> > >
> > > http://www.oracledba.co.uk
> > >
> > > "Some days you're the pigeon, some days you're the statue..."
> >
> > I think Jonathan Lewis was saying this in his book.
> >
> > The idea is that for the second one, Oracle has to make sure that the
> > second row is NOT returned from the query, because an
> > TOO_MANY_ROWS exception is also some piece of information
> > that can be returned from the query. The first just does a single fetch,
> > the second does two.
> >
> > IMO makes a lot of sense

>

> Try putting a trace on and look at the results...You'll see (from 7.3
> onwards, possibly even earlier) that a second fetch is not required.
>

> A quick look in JL's book and I cannot find any references in the PL/SQL
> or Tuning chapters that make any reference to the statements you've
> made.
>

> hth
> connor
> --
> ==============================
> Connor McDonald
>

> http://www.oracledba.co.uk

>
> "Some days you're the pigeon, some days you're the statue..."
Received on Tue Aug 06 2002 - 23:52:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US