[20170506]fetch sqlplus arraysize.txt

[20170506]fetch sqlplus arraysize.txt

http://blog.itpub.net/267265/viewspace-2138042/

--//前一阵子写的,如果设置arrarsize=3,可以看到3条3条输出.
--//里面提到4秒,是因为第一次提取1条,然后在提取3条,输出3条,在输出缓存保留1条,如此循环.
--//实际上使用10046跟踪也能观察到这种现象.

1.环境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.1.0.1.0     Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0

SCOTT@test01p> set arraysize 3

SCOTT@test01p> @ 10046on 12
old   1: alter session set events '10046 trace name context forever, level &1'
new   1: alter session set events '10046 trace name context forever, level 12'
Session altered.

SCOTT@test01p> select * from emp ;
EMPNO ENAME  JOB        MGR HIREDATE             SAL COMM DEPTNO
----- ------ --------- ---- ------------------- ---- ---- ------
 7369 SMITH  CLERK     7902 1980-12-17 00:00:00  800          20
 7499 ALLEN  SALESMAN  7698 1981-02-20 00:00:00 1600  300     30
 7521 WARD   SALESMAN  7698 1981-02-22 00:00:00 1250  500     30
 7566 JONES  MANAGER   7839 1981-04-02 00:00:00 2975          20
 7654 MARTIN SALESMAN  7698 1981-09-28 00:00:00 1250 1400     30
 7698 BLAKE  MANAGER   7839 1981-05-01 00:00:00 2850          30
 7782 CLARK  MANAGER   7839 1981-06-09 00:00:00 2450          10
 7788 SCOTT  ANALYST   7566 1987-04-19 00:00:00 3000          20
 7839 KING   PRESIDENT      1981-11-17 00:00:00 5000          10
 7844 TURNER SALESMAN  7698 1981-09-08 00:00:00 1500    0     30
 7876 ADAMS  CLERK     7788 1987-05-23 00:00:00 1100          20
 7900 JAMES  CLERK     7698 1981-12-03 00:00:00  950          30
 7902 FORD   ANALYST   7566 1981-12-03 00:00:00 3000          20
 7934 MILLER CLERK     7782 1982-01-23 00:00:00 1300          10
14 rows selected.

SCOTT@test01p> @ 10046off
Session altered.

2.观察跟踪文件:
PARSING IN CURSOR #357077368 len=18 dep=0 uid=109 oct=3 lid=109 tim=8967176038 hv=862079893 ad='7ff1cb55268' sqlid='g5wp7pwtq4kwp'
select * from emp
END OF STMT
PARSE #357077368:c=109201,e=305055,p=21,cr=608,cu=0,mis=1,r=0,dep=0,og=1,plh=3956160932,tim=8967176037
EXEC #357077368:c=0,e=113,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=3956160932,tim=8967176252
WAIT #357077368: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=275 tim=8967176337
WAIT #357077368: nam='Disk file operations I/O' ela= 125 FileOperation=2 fileno=9 filetype=2 obj#=92287 tim=8967176534
WAIT #357077368: nam='db file sequential read' ela= 10710 file#=9 block#=146 blocks=1 obj#=92287 tim=8967187272
WAIT #357077368: nam='db file scattered read' ela= 610 file#=9 block#=147 blocks=5 obj#=92287 tim=8967188102
FETCH #357077368:c=0,e=11810,p=6,cr=5,cu=0,mis=0,r=1,dep=0,og=1,plh=3956160932,tim=8967188191
WAIT #357077368: nam='SQL*Net message from client' ela= 350 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967188631
WAIT #357077368: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967188693
FETCH #357077368:c=0,e=41,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967188721
WAIT #357077368: nam='SQL*Net message from client' ela= 248 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189004
WAIT #357077368: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189047
FETCH #357077368:c=0,e=36,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967189075
WAIT #357077368: nam='SQL*Net message from client' ela= 170 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189277
WAIT #357077368: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189331
FETCH #357077368:c=0,e=36,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967189357
WAIT #357077368: nam='SQL*Net message from client' ela= 170 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189566
WAIT #357077368: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189617
FETCH #357077368:c=0,e=37,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967189644
WAIT #357077368: nam='SQL*Net message from client' ela= 169 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189853
WAIT #357077368: nam='SQL*Net message to client' ela= 0 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8967189899
FETCH #357077368:c=0,e=41,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=1,plh=3956160932,tim=8967189933
STAT #357077368 id=1 cnt=14 pid=0 pos=1 obj=92287 op='TABLE ACCESS FULL EMP (cr=12 pr=6 pw=0 time=11800 us cost=3 size=532 card=14)'
*** 2017-05-06 20:16:17.450
WAIT #357077368: nam='SQL*Net message from client' ela= 6502696 driver id=1413697536 #bytes=1 p3=0 obj#=92287 tim=8973692722
CLOSE #357077368:c=0,e=20,dep=0,type=0,tim=8973692991
=====================

D:\temp>grep FETCH aa.txt
FETCH #357077368:c=0,e=11810,p=6,cr=5,cu=0,mis=0,r=1,dep=0,og=1,plh=3956160932,tim=8967188191
FETCH #357077368:c=0,e=41,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967188721
FETCH #357077368:c=0,e=36,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967189075
FETCH #357077368:c=0,e=36,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967189357
FETCH #357077368:c=0,e=37,p=0,cr=1,cu=0,mis=0,r=3,dep=0,og=1,plh=3956160932,tim=8967189644
FETCH #357077368:c=0,e=41,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=1,plh=3956160932,tim=8967189933

--//注意看每行r=N的内容1,3,3,3,3,1.从这里也可以看出fetch的数量变化.
--//总之,先取1条,再取ayysize条,输出arraysize条,再输出缓存中保留1条,如此循环,取出全部记录.

时间: 2024-07-30 10:50:41

[20170506]fetch sqlplus arraysize.txt的相关文章

[20170916]sqlplus set array最小2补充.txt

[20170916]sqlplus set array最小2补充.txt --//以前写的贴子,链接http://blog.itpub.net/267265/viewspace-1453652/ --//上面提到设置array=1或者array=2.执行sql语句输出的逻辑读是一样的,所以得到一个结论. --//set array最小是2. --//我也在http://blog.itpub.net/267265/viewspace-2138596/里面提到.fetch 与arraysize的关系

smarty中capture,literal,fetch用法

1,capture标签 capture的中文意思是抓取,它的作用是抓取模板输出的数据,当我们需要它的时候,调用它,以得到抓取数据的目的.例子:  代码如下 复制代码 1.{capture name=test} 2.<img src="testimg.jpg"> 3.{/capture} 4.<div class="image"> 5.{$smarty.capture.test} 6.</div> 说明: 在{capture nam

【Oracle】一款非常好用的trace文件分析工具之二

前一篇文章介绍了如何安装trca,接下来介绍如何使用trca:必须进入 trca/run 目录里面 或者把 /home/oracle/software/trca/run 放到SQL_PATH环境变量里面: 使用trcanlzr.sql的时候可以直接跟trace 文件名字,该工具默认会到user_dump_dest 里面去找(对于10g以前的,会到bdump_dest 里面去找跟踪文件) sys@RAC> show parameter user_dump_dest NAME            

几个smarty小技巧

1,capture标签 capture的中文意思是抓取,它的作用是抓取模板输出的数据,当我们需要它的时候,调用它,以得到抓取数据的目的.例子: Java代码   {capture name=test}       <img src="testimg.jpg">   {/capture}   <div class="image">       {$smarty.capture.test}   </div>    说明: 在{capt

php smarty模板引擎的6个小技巧_php技巧

下面本文将以具体的例子一一分析: capture标签 capture的中文意思是抓取,它的作用是抓取模板输出的数据,当我们需要它的时候,调用它,以得到抓取数据的目的.如下例子: 复制代码 代码如下: {capture name="test"} <img src="testimg.jpg"> {/capture} <div class="image"> {$smarty.capture.test} </div>

[20140823]在sqlplus使用copy注意.txt

[20140823]在sqlplus使用copy注意.txt --有时候使用copy来复制表数据,但是前几天我的测试遇到一些小问题,做一个记录,总之还是小心注意这些细节. SCOTT@test01p> @ver BANNER                                                                               CON_ID ----------------------------------------------------

[20150309]sqlplus set array最小2.txt

[20150309]sqlplus set array最小2.txt --上午做测试发现1个问题,设置array=1是无效的,在sqlplus下set array最小是2.自己做一个人测试: 1.建立测试环境: SCOTT@test> @ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- ---------------------------

Oracle sqlplus的arraysize

场景描述  开始我觉得这是个神奇的事情.u1用户的t1表共有大约1230块,但是对该表进行全表扫描的时候(select *),竟需要consistent gets接近7000次.  因为从正常的逻辑来理解,block从物理设备读取到内存,然后cpu从内存读取数据进行计算/过滤,这是一个完整的过程.如果内存中有缓存的block,那么就可以不用经历物理设备读取block的过程,这么看来,consistent gets应该是不大于physical reads的才对. arraysize参数 这里先简单

[20170617]vim中调用sqlplus.txt

[20170617]vim中调用sqlplus.txt --//以前写过一篇emacs下调用sqlplus的文章,一直想学emacs,受限制自己掌握vim,对学习它没有兴趣,原链接如下: --//http://blog.itpub.net/267265/viewspace-1309032/ --//实际上vim也有插件连接数据库,我觉得不好用,一直没这样用. --//今天在整理vim相关设置时,发现我自己以前也定义一些方法,自己也拿出来分享: noremap  <Leader>q1 Yp!!s