温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle arraysize的研究是怎样的

发布时间:2021-11-12 09:32:43 来源:亿速云 阅读:154 作者:柒染 栏目:关系型数据库

Oracle arraysize的研究是怎样的,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。


  1. SYS@proc> desc aaa;

  2.  Name                                      Null?    Type

  3.  ----------------------------------------- -------- ----------------------------

  4.  ID1                                                NUMBER(38)

  5.  ID2                                                NUMBER(38)

  6.  ID3                                                NUMBER(38)

  7.  ID4                                                NUMBER(38)


  8. SYS@proc> select * from aaa;


  9.        ID1        ID2           ID3        ID4

  10. ---------- ---------- ---------- ----------

  11.          1            1                1          1

  12.          1             1               1           0


  13. SYS@proc> select * from aaa1;


  14.        ID1         ID2           ID3        ID4

  15. ---------- ---------- ---------- ----------

  16.          1            1               1           0

  17.          1            1                1           1


  18. SYS@proc> select * from aaa where id1/id2=1 and id3/id4=1;

  19. ERROR:

  20. ORA-01476: divisor is equal to zero




  21. no rows selected


  22. SYS@proc> set arraysize 1

  23. SYS@proc> /


  24.        ID1        ID2           ID3        ID4

  25. ---------- ---------- ---------- ----------

  26.          1             1                1           1

  27. ERROR:

  28. ORA-01476: divisor is equal to zero




  29. SYS@proc> select * from aaa1 where id1/id2=1 and id3/id4=1;

  30. select * from aaa1 where id1/id2=1 and id3/id4=1

  31.                                           *

  32. ERROR at line 1:

  33. ORA-01476: divisor is equal to zero

  1. SYS@proc> drop table aaa2 purge;


  2. Table dropped.


  3. SYS@proc> create table aaa2 (id1 int,id2 int,id3 int,id4 int,flag int);


  4. Table created.


  5. SYS@proc> insert into aaa2 values(1,1,1,1,1);


  6. 1 row created.


  7. SYS@proc> insert into aaa2 values(1,1,1,1,2);


  8. 1 row created.


  9. SYS@proc> insert into aaa2 values(1,1,1,1,3);


  10. 1 row created.


  11. SYS@proc> insert into aaa2 values(1,1,1,1,4);


  12. 1 row created.


  13. SYS@proc> insert into aaa2 values(1,1,1,1,5);


  14. 1 row created.


  15. SYS@proc> insert into aaa2 values(1,1,1,1,6);


  16. 1 row created.


  17. SYS@proc> insert into aaa2 values(1,1,1,1,7);


  18. 1 row created.


  19. SYS@proc> insert into aaa2 values(1,1,1,1,8);


  20. 1 row created.


  21. SYS@proc> insert into aaa2 values(1,1,1,1,9);


  22. 1 row created.


  23. SYS@proc> insert into aaa2 values(1,1,1,1,10);


  24. 1 row created.


  25. SYS@proc> insert into aaa2 values(1,1,1,0,0);


  26. 1 row created.


  27. SYS@proc> commit;


  28. Commit complete.


  29. SYS@proc> analyze table aaa2 compute statistics;


  30. Table analyzed.


  31. SYS@proc> set arraysize 1

  32. SYS@proc> select * from aaa2 where id1/id2=1 and id3/id4=1;


  33.        ID1         ID2           ID3        ID4        FLAG

  34. ---------- ---------- ---------- ---------- ----------

  35.          1             1               1           1             1

  36.          1             1               1           1             2

  37.          1             1               1          1             3

  38.          1             1               1           1              4

  39.          1          1               1           1             5

  40.          1             1               1           1              6

  41.          1             1                1          1             7

  42.          1          1               1           1              8

  43.          1            1                1           1             9

  44. ERROR:

  45. ORA-01476: divisor is equal to zero




  46. 9 rows selected.

  47. --从大量结果上看,arraysize为1或者2是一样的。这里为9预见。


  48. SYS@proc> select * from aaa2;


  49.        ID1        ID2            ID3        ID4       FLAG

  50. ---------- ---------- ---------- ---------- ----------

  51.          1            1                1           1              1

  52.          1             1                1          1              2

  53.          1            1                1           1              3

  54.          1             1               1          1             4

  55.          1            1                1           1              5

  56.          1             1                1          1             6

  57.          1             1               1          1             7

  58.          1          1          1          1             8

  59.          1            1               1          1             9

  60.          1            1                1          1           10

  61.          1            1                1           0              0


  62. 11 rows selected.


  63. SYS@proc>

  1. SYS@proc> set arraysize 2

  2. SYS@proc> select * from aaa2 where id1/id2=1 and id3/id4=1;


  3.        ID1      ID2         ID3    ID4      FLAG

  4. ---------- ---------- ---------- ---------- ----------

  5.      1        1           1      1         1

  6.      1        1           1      1         2

  7.      1        1           1      1         3

  8.      1        1           1      1         4

  9.      1        1           1      1         5

  10.      1        1           1      1         6

  11.      1        1           1      1         7

  12.      1        1           1      1         8

  13. ERROR:

  14. ORA-01476: divisor is equal to zero




  15. 8 rows selected.

语句对应的10046,可以看出是返回了9行,但是从上边看是8行,很奇怪。

  1. PARSING IN CURSOR #140496887317072 len=48 dep=0 uid=0 oct=3 lid=0 tim=1514130832420098 hv=3007681721 ad='812bd000' sqlid='7cfwyuytnb55t'

  2. select * from aaa2 where id1/id2=1 and id3/id4=1

  3. END OF STMT

  4. PARSE #140496887317072:c=0,e=1221,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,plh=2576342259,tim=1514130832420093

  5. EXEC #140496887317072:c=0,e=24,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=2576342259,tim=1514130832420198

  6. WAIT #140496887317072: nam='SQL*Net message to client' ela= 5 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832420238

  7. FETCH #140496887317072:c=0,e=64,p=0,cr=2,cu=0,mis=0,r=1,dep=0,og=1,plh=2576342259,tim=1514130832420331

  8. WAIT #140496887317072: nam='SQL*Net message from client' ela= 476 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832420842

  9. WAIT #140496887317072: nam='SQL*Net message to client' ela= 3 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832420907

  10. FETCH #140496887317072:c=0,e=36,p=0,cr=1,cu=0,mis=0,r=2,dep=0,og=1,plh=2576342259,tim=1514130832420924

  11. WAIT #140496887317072: nam='SQL*Net message from client' ela= 146 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421092

  12. WAIT #140496887317072: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421137

  13. FETCH #140496887317072:c=0,e=28,p=0,cr=1,cu=0,mis=0,r=2,dep=0,og=1,plh=2576342259,tim=1514130832421151

  14. WAIT #140496887317072: nam='SQL*Net message from client' ela= 66 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421237

  15. WAIT #140496887317072: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421277

  16. FETCH #140496887317072:c=0,e=26,p=0,cr=1,cu=0,mis=0,r=2,dep=0,og=1,plh=2576342259,tim=1514130832421290

  17. WAIT #140496887317072: nam='SQL*Net message from client' ela= 60 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421369

  18. WAIT #140496887317072: nam='SQL*Net message to client' ela= 1 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421407

  19. FETCH #140496887317072:c=0,e=25,p=0,cr=1,cu=0,mis=0,r=2,dep=0,og=1,plh=2576342259,tim=1514130832421420

  20. WAIT #140496887317072: nam='SQL*Net message from client' ela= 410 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421848

  21. WAIT #140496887317072: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832421907

  22. FETCH #140496887317072:c=0,e=63,p=0,cr=1,cu=0,mis=0,r=1,dep=0,og=1,plh=2576342259,tim=1514130832421956

  23. STAT #140496887317072 id=1 cnt=10 pid=0 pos=1 obj=88977 op='TABLE ACCESS FULL AAA2 (cr=7 pr=0 pw=0 time=94 us cost=2 size=10 card=1)'

  24. WAIT #140496887317072: nam='SQL*Net break/reset to client' ela= 28 driver id=1650815232 break?=1 p3=0 obj#=-1 tim=1514130832422110

  25. WAIT #140496887317072: nam='SQL*Net break/reset to client' ela= 120 driver id=1650815232 break?=0 p3=0 obj#=-1 tim=1514130832422252

  26. WAIT #140496887317072: nam='SQL*Net message from client' ela= 595 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1514130832422889

  27. CLOSE #140496887317072:c=0,e=14,dep=0,type=0,tim=1514130832422981

  28. =====================

所以其实arraysize是1还是2,还是存在区别的。不过从10046上看却是没多大区别,从全表扫描或者其他能够正常返回结果的情况下,值为1和2是完全一样的。

但是实际上无论arraysize的值是多少,默认第一行单独会直接发送反馈给用户的,所以应该是不用设置的。
后边研究的逻辑读也有点问题,在12C里边差别更大。

看完上述内容,你们掌握Oracle arraysize的研究是怎样的的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI