no, not true.
"It need not goto the database data *at all*."
it removes the need to actually do a full scan, but it is still SQL. It still context switches from plsql to sql.
ops$tkyte@ORA10G> drop sequence s;
Sequence dropped.
ops$tkyte@ORA10G> create sequence s;
Sequence created.
ops$tkyte@ORA10G> select s.nextval from dual;
NEXTVAL
----------
1
ops$tkyte@ORA10G> exec runStats_pkg.rs_start;
PL/SQL procedure successfully completed.
ops$tkyte@ORA10G> declare
2 l_s_currval number;
3 l_var number;
4 begin
5 select s.currval into l_s_currval from dual;
6 for i in 1 .. 100000
7 loop
8 l_var := l_s_currval;
9 end loop;
10 end;
11 /
PL/SQL procedure successfully completed.
ops$tkyte@ORA10G> exec runStats_pkg.rs_middle;
PL/SQL procedure successfully completed.
ops$tkyte@ORA10G> declare
2 l_var number;
3 begin
4 for i in 1 .. 100000
5 loop
6 select s.currval into l_var from dual;
7 end loop;
8 end;
9 /
PL/SQL procedure successfully completed.
ops$tkyte@ORA10G> exec runStats_pkg.rs_stop(100)
Run1 ran in 2 hsecs
Run2 ran in 335 hsecs
run 1 ran in .6% of the time
<b>so, less wall clock and</b>
Name Run1 Run2 Diff
LATCH.cache buffers chains 3,614 3,471 -143
STAT...recursive cpu usage 3 258 255
STAT...CPU used when call star 7 322 315
STAT...CPU used by this sessio 7 322 315
STAT...DB time 10 337 327
STAT...Elapsed Time 4 340 336
STAT...undo change vector size 47,632 46,308 -1,324
STAT...redo size 100,504 95,744 -4,760
STAT...recursive calls 105 100,005 99,900
LATCH.shared pool 266 100,227 99,961
STAT...execute count 17 100,005 99,988
STAT...calls to get snapshot s 8 100,001 99,993
STAT...session pga memory 0 131,072 131,072
LATCH.library cache 249 200,140 199,891
LATCH.library cache pin 141 200,066 199,925
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
4,627 504,310 499,683 .92%
PL/SQL procedure successfully completed.
<b>lots less latching...
In 9i, it might look like the following</b>
ops$tkyte@ORA9IR2> exec runStats_pkg.rs_stop(100)
Run1 ran in 11 hsecs
Run2 ran in 425 hsecs
run 1 ran in 2.59% of the time
Name Run1 Run2 Diff
LATCH.simulator hash latch 135 0 -135
STAT...recursive cpu usage 1 342 341
STAT...CPU used by this sessio 2 407 405
STAT...CPU used when call star 2 407 405
STAT...Elapsed Time 17 429 412
STAT...redo size 70,104 65,008 -5,096
STAT...session pga memory max 8,524 0 -8,524
STAT...session pga memory 0 65,536 65,536
STAT...recursive calls 111 100,004 99,893
LATCH.shared pool 246 100,220 99,974
STAT...execute count 18 100,005 99,987
STAT...buffer is not pinned co 4 100,000 99,996
STAT...no work - consistent re 4 100,000 99,996<b>
STAT...table scan blocks gotte 1 100,000 99,999
STAT...table scan rows gotten 1 100,000 99,999
STAT...table scans (short tabl 1 100,000 99,999</b>
LATCH.library cache pin 189 200,118 199,929
LATCH.library cache 355 200,285 199,930
STAT...session logical reads 582 300,523 299,941
STAT...consistent gets 26 300,003 299,977
STAT...calls to get snapshot s 19 300,001 299,982<b>
LATCH.cache buffers chains 2,734 602,621 599,887</b>
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
4,418 1,104,108 1,099,690 .40%
PL/SQL procedure successfully completed.
<b>the stuff in bold shows the actual IO's performed against dual...</b>