Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Cool 10G performance improvement
Saw this on asktom.oracle.com(very cool performance improvement, easy to
use)
Reviewer: Zoran Martic from Dublin, Ireland
Hi Tom,
Now I found why is good sometimes folowing your path.
You said using constructs like this is the best and very easy to use:
for i in (select * from table_x) loop
In 10g Oracle finally optimizes this thing to use some sort of prefetching
and
it went 10x faster in my simple test then in 9i or 8i.
I was thinking why and how, but basically statistics showed me that on 8i
and
9i, both explicit and implicit cursors are doing 1 db block read per one
fetch
(disaster that Oracle is doing this when you have in OCI prefetching from XX
release of Oracle). In 10g they are finally optimizing fetches but only for
implicit cursors :)
That means who ever coded for loops with Select inside will benefit
immediately
with upgrade to 10g.
In 9i you need to opt to BULK COLLECT to be fast as 10g normal for i in
(select
....
Again, explicit cursors are working bad as in 8i, 9i story.
That is a shame for Oracle.
No reason that new smart optimizer cannot find out that you are going to
loop in
both cases: implicit or explicit.
Did not put tests and results because they are too obvious (10 lines of
code).
Just loop through some big table and check that you are not hitting funny
disks
to make your results pointless.
In any case I wrote a lot of code your way with putting SQL inside the for
loop
and I am happy now, because upgrade to 10g will automatically benefit me :)
It is very strange that I realize now, after many years that this thing
(looping
through cursors) in PL/SQL was that bad. Without prefetching (I used from
Oracle
7.3) in PL/SQL in 8i, 9i !!!!!
Regards,
Zoran
Followup:
oh, that is cool -- I did not even realize that was happening :)
It is trivial to show, just:
begin
for x in ( select * from all_objects where rownum < 10000)
loop
null;
end loop;
end;
and in 9i, you'll see:
select *
from
all_objects where rownum < 10000
call count cpu elapsed disk query current
rows
------- ------ -------- ---------- ---------- ---------- ---------- ------
and in 10g, you'll see:
SELECT *
FROM
ALL_OBJECTS WHERE ROWNUM < 10000
call count cpu elapsed disk query current
rows
------- ------ -------- ---------- ---------- ---------- ---------- ------
they are using a 100 (my favorite) row arraysize....
:)
-- Jim Kennedy It is unnecessary to repeat the same old mistake when you can make so many interesting new ones. - Bertrand RussellReceived on Sat Feb 07 2004 - 17:14:04 CST
![]() |
![]() |