实践分析:

最开始在statement 上面设置fetchsize的原因是想增加查询结果返回的速度,因为这样一下子就可以返回更多的数据,但是实际上当我们加上这个条件的时候,没有起到效果,反而慢了下来,原因不知道。对于fetchsize的用法参考官方说明:

Fetch Size

By default, when Oracle JDBC executes a query, it receives the result set 10 rows at a time from the database cursor. This is the default Oracle row-prefetch value. You can change the number of rows retrieved with each trip to the database cursor by changing the row-prefetch value (see "Oracle Row Prefetching" for more information).

JDBC 2.0 also allows you to specify the number of rows fetched with each database round trip for a query, and this number is referred to as the fetch size. In Oracle JDBC, the row-prefetch value is used as the default fetch size in a statement object. Setting the fetch size overrides the row-prefetch setting and affects subsequent queries executed through that statement object.

Fetch size is also used in a result set. When the statement object executes a query, the fetch size of the statement object is passed to the result set object produced by the query. However, you can also set the fetch size in the result set object to override the statement fetch size that was passed to it. (Also note that changes made to a statement object's fetch size after a result set is produced will have no affect on that result set.)

The result set fetch size, either set explicitly, or by default equal to the statement fetch size that was passed to it, determines the number of rows that are retrieved in any subsequent trips to the database for that result set. This includes any trips that are still required to complete the original query, as well as any refetching of data into the result set. (Data can be refetched, either explicitly or implicitly, to update a scroll-sensitive or scroll-insensitive/updatable result set. See "Refetching Rows".)

Setting the Fetch Size

The following methods are available in all Statement, PreparedStatement, CallableStatement, and ResultSet objects for setting and getting the fetch size:

void setFetchSize(int rows) throws SQLException

int getFetchSize() throws SQLException

To set the fetch size for a query, call setFetchSize() on the statement object prior to executing the query. If you set the fetch size to N, then N rows are fetched with each trip to the database.

After you have executed the query, you can call setFetchSize() on the result set object to override the statement object fetch size that was passed to it. This will affect any subsequent trips to the database to get more rows for the original query, as well as affecting any later refetching of rows. (See "Refetching Rows".)

Use of Standard Fetch Size versus Oracle Row-Prefetch Setting

Using the JDBC 2.0 fetch size is fundamentally similar to using the Oracle row-prefetch value, except that with the row-prefetch value you do not have the flexibility of distinct values in the statement object and result set object. The row prefetch value would be used everywhere.

Furthermore, JDBC 2.0 fetch size usage is portable and can be used with other JDBC drivers. Oracle row-prefetch usage is vendor-specific.

See "Oracle Row Prefetching" for a general discussion of this Oracle feature.

Note:

Do not mix the JDBC 2.0 fetch size API and the Oracle row prefetching API in your application. You can use one or the other, but not both.

oracle中的fetchsize,oracle setFetchsize() 优化查询速度相关推荐

  1. 【DB笔试面试615】在Oracle中,和谓词相关的查询转换有哪些?

    ♣题目部分 在Oracle中,和谓词相关的查询转换有哪些? ♣答案部分 (一)过滤谓词推入 1LHR@orclasm > SELECT * FROM (SELECT * FROM VW_SVM_ ...

  2. 【DB笔试面试614】在Oracle中,和视图相关的查询转换有哪些?

    ♣题目 部分 在Oracle中,和视图相关的查询转换有哪些? ♣答案部分 (一)简单视图合并 1CREATE OR REPLACE VIEW VW_SVM_LHR AS SELECT * FROM S ...

  3. 【DB笔试面试618】在Oracle中,“OR扩展”可以有查询转换吗?

    ♣题目 部分 在Oracle中,"OR扩展"可以有查询转换吗? ♣答案部分 同一字段: 1LHR@orclasm > SELECT * FROM SCOTT.EMP A WH ...

  4. oracle中的to_number,Oracle中to_number()函数的用法

    to_number()函数是oracle中常用的类型转换函数之一,是将一些处理过的按一定格式编排过的字符串变回数值型的格式. 1.to_number()函数可以将char或varchar2类型的str ...

  5. oracle中rollback用法,Oracle中SAVEPOINT和ROLLBACK用法

    savepoint是事务内部允许部分rollback的标志符.因为事务中对记录做了修改,我们可以在事务中创建savepoint来标识不同的点.如果遇到错误,就可以rollback到不同的点或直接回来事 ...

  6. oracle临时表性能,oracle临时表-优化查询速度

    目前所有使用oracle作为数据库支撑平台的应用,大部分数据量比较庞大的系统,即表的数据量一般情况下都是在百万级以上的数据量.[@more@] 当然在oracle中创建分区是一种不错的选择,但是当你发 ...

  7. oracle加强制索引,Oracle中建立索引并强制优化器使用

    当WHERE子句对某一列使用函数时,除非利用这个简单的技术强制索引,否则Oracle优化器不能在查询中使用索引. 通常情况下,如果在WHERE子句中不使用诸如UPPER.REPLACE 或SUBSTR ...

  8. oracle中的备注的配置与查询

    在oracle中我们经常看到给表和列添加备注,备注增加了后期的可维护性 1.对表的说明 comment on table table_name is 'comments'; 2.对表中列的说明 com ...

  9. Oracle中限定日期,Oracle 日期的一些简单使用

    Oracle 日期的一些简单使用 更新时间:2009年08月04日 16:52:35   作者: 学习了这么长的数据库,突然意识到自己对于数据库主外键的意义完全弄不懂,是唯一标识一条记录,是为连接查询 ...

最新文章

  1. 长连接及在Node中的应用——HTTP/1.1 keep-alive
  2. 4k视频写入速度要求_为什么视频工作者需要外置硬盘?
  3. JavaScript实现degreeToRadian度到弧度算法(附完整源码)
  4. mysql scott用户_在mysql中创建 oracle scott 用户的四个表及插入初始化数据
  5. vue cli3.0创项目报错‘This may cause things to work incorrectly. Make sure to use the same version for b’
  6. mysql导入创建表空间_oracle创建表空间 导入数据库
  7. (转)Spring Boot 2 (九):【重磅】Spring Boot 2.1.0 权威发布
  8. 初识Opserver,StackExchange的监控解决方案
  9. CSS-样式表插入的三种方法、背景(background)、文本
  10. css 主页模版 搜索技巧
  11. ad中按钮开关的符号_收藏:电路图形符号大全!!!
  12. C语言arduino密码锁实验报告,简易密码锁的制作-Arduino中文社区 - Powered by Discuz!...
  13. java毕业论文云笔记_《毕业设计指导的系统设计与实现》论文笔记(八)
  14. C语言:甲乙丙三人放鞭炮,求鞭炮响声问题
  15. 干货分享 | FMEA何时做?谁来做?
  16. 勇立潮头,推动国产数据库产业崛起—“金兰生态 仓起辉煌·2020人大金仓生态大会暨新战略发布会”在京成功召开...
  17. unity-shader-ShaderGraph可视化shader
  18. BIO NIO AIO 介绍与差别
  19. 华为服务器怎么恢复系统,服务器恢复系统
  20. c语言来自不兼容指针类型的分配,c - 为什么我会收到“警告:来自不兼容指针类型的分配”? 结构数组中的双链表 - 堆栈内存溢出...

热门文章

  1. 什么是RAID(独立磁盘冗余阵列)?
  2. FD.io VPP:用户文档:VPP RPM包的构建与离线安装
  3. mediawiki 编辑php代码,mediawiki_1.25配置wikieditor编辑器
  4. 100个灯泡python编程_算法题:一个圆环上有100个灯泡,灯泡有打...
  5. Django:模型层ORM
  6. python3 format函数_【Python3 第三日】%和format格式化输出 函数
  7. java工厂模式学习
  8. listView使用checkBox的实现
  9. java数学函数Math类
  10. linux sed后 保存文本,实例详解linux文本三剑客--sed