从数据库中检索一百万条记录 [英] Retrieving a million records from a database

查看:196
本文介绍了从数据库中检索一百万条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个数据库,它包含大约在表中的200万条记录。我从我的java代码像这样select * from table运行查询。将从结果集中的数据库获取完整的数据。或不 。如果是,那么如何工作,我想学习在这个检索工作,

There is a database it contains 2 million records approx in a table . and i ran the query from my java code like this " select * from table" . will it fetch the complete data from the database in the result set . or not . If yes then how it will work i want to learn the working on this retrieveal ,

请让我知道,我学到了一个地方,它会从检索完整的数据从数据库,并将存储在临时存储从那里它将显示在输出。很好。
或者有与J2C相关的东西

Please let me know , i have learnt somewhere that it will retrieve the complete data from the database and will store in the temporary storage from there it will show in the output .Is it fine . Or is there something related to J2C

推荐答案

是否从数据库中获取完整的数据结果集

没有精确的答案。它总是依赖于数据库驱动程序。结果集是一个接口,其实现由特定的数据库驱动程序完成。 ResultSet实现可以具有其自己的优化,其中对于较小的数据集,对于较大的数据集,其缓冲(或一些默认分页机制),提取一切。所以,请参考数据库驱动程序文档。

There is no precise answer to it. Its always dependent on the database driver. The result set is an Interface and its implementation is done by a specific database driver. The ResultSet implementation may have its own optimization wherein for smaller set of data, everything is fetched where as for larger datasets, its buffered (or some default paging mechanism). So please refer to the database driver documentation.

有一个标准(至少javadoc说这么做)防止从数据库获取大数据。为JDBC语句设置适当的提取大小如下 java.sql.Statement.setFetchSize()

There is a standard (at least the javadoc says so) way out to prevent the fetching of large data from database. Set the appropriate fetch size for the JDBC statement as follows java.sql.Statement.setFetchSize().

像java doc


给JDBC驱动程序提示当需要更多行时,应从数据库获取的
的行数。指定的
行的数量仅影响使用此语句创建的结果集。
如果指定的值为零,则忽略提示。默认的
值为零。

Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified affects only result sets created using this statement. If the value specified is zero, then the hint is ignored. The default value is zero.

希望这有帮助。

这篇关于从数据库中检索一百万条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆