QUOTE:
原帖由
晶晶小妹 于 2008-6-23 03:43 发表

在执行时,并不去读取行。ORACLE中的“执行”,是根据执行计划,做好一切读取行的准备工作。等到用户传来Fetch抓取命令时,马上开始读取行。
Interesting observation. I can prove it this way:
declare
c integer;
ret integer;
colval number;
mysql varchar2(2000);
begin
mysql := 'select a.x from t a, t b'; -- t is just a table with some rows
c := dbms_sql.open_cursor;
dbms_sql.parse(c, mysql, dbms_sql.native);
dbms_sql.define_column(c, 1, colval);
ret := dbms_sql.execute(c);
dbms_lock.sleep(30);
while not (dbms_sql.fetch_rows(c) <= 0) loop
dbms_sql.column_value(c, 1, colval);
dbms_output.put_line('The value is: ' || colval);
end loop;
dbms_sql.close_cursor(c);
exception
when others then
dbms_output.put_line('Error: ' || sqlerrm);
end;
/
In another session, check this session's "session logical read" in v$sesstat before running the PL/SQL, during the 30 second sleep, and during or after running the fetches. Most of the logical reads are during the fetch phase.
Yong Huang