简体   繁体   English

perl批量选择Oracle中的DBI

[英]perl bulk select DBI IN Oracle

Need to retrieve 200000 records from a table and do processing on each record. 需要从表中检索200000条记录,并对每个记录进行处理。 The database is oracle. 该数据库是oracle。 Currently Using fetch_rowarrayref method and doing processing on each record. 当前使用fetch_rowarrayref方法并对每个记录进行处理。 For huge amount of record is it efficient to have a fetch limit like 5000 records and looping. 对于大量记录,具有5000条记录和循环之类的访存限制非常有效。 Mysql has a LIMIT keyword but oracle doesn't have it. Mysql有LIMIT关键字,但oracle没有。 Not sure how in dbi i can do it. 不知道如何在dbi中我能做到。

Fetch 5000 records into a array Do the processing from the array Fetch again till it reached 100000 records 将5000条记录取到一个数组中从数组中进行处理再次取回直到达到100000条记录

Using pagination will not be more efficient than what you are doing. 使用分页不会比您正在做的事更有效率。 The point of pagination would be to avoid running out of memory, but if you are not (and Oracle should not with DBD::Oracle) then there is nothing gained by that. 分页的目的是避免内存不足,但是如果不是这样(Oracle不应使用DBD :: Oracle),那么这样做将毫无用处。

If this operation is too slow, then you have several basic options. 如果此操作太慢,则有几种基本选项。

  1. Do the dump closer to the database (less latency). 使转储靠近数据库(减少延迟)。
  2. Select less data. 选择较少的数据。
  3. Have several processes querying in parallel. 有几个并行查询的进程。
  4. Use a special purpose bulk export tool. 使用专用的批量导出工具。
  5. Reset expectations so that you can live with it. 重设期望值,以便您可以忍受。

Your task looks like pagination in fetching data and processing on it, to write a pagination type query 您的任务就像在获取数据并对其进行处理以编写分页类型查询时的分页一样

select *
 from (
select /*+ first_rows(25) */
  your_columns,
  row_number() 
  over (order by something unique)rn
 from your_tables )
where rn between :n and :m 
order by rn;

:n = Starting Row :m = End Row rn = Column to Perform Sorting :n =起始行:m =结束行rn =执行排序的列

for more information u can refer to link #1 or link #2 有关更多信息,您可以参考链接1链接2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM