对300万一张表数据,用游标进行循环,不同写法的效率比较
2017-02-14 16:12
453 查看
1、显示游标
declare
cursor cur_2 is select a.cust_name from ea_cust.cust_info a;
cust_id varchar2(100);
begin
open cur_2;
loop
fetch cur_2 into cust_id;
exit when cur_2%notfound;
NULL;
end loop;
close cur_2;
end;
--耗时48秒
2、隐式游标
declare
begin
for cur_2 in (select c.cust_name from ea_cust.cust_info c) loop
NULL;
end loop;
end;
--耗时16秒
3、bulk collect into + cursor
declare
cursor cur_3 is select a.cust_name from ea_cust.cust_info a;
type t_table is table of varchar2(100);
c_table t_table;
to_cust_id varchar2(100);
begin
open cur_3;
loop
fetch cur_3 bulk collect into c_table limit 100;
exit when c_table.count = 0;
for i in c_table.first..c_table.last loop
null;
end loop;
end loop;
commit;
end;
--耗时13秒,看样子这种最快
declare
cursor cur_2 is select a.cust_name from ea_cust.cust_info a;
cust_id varchar2(100);
begin
open cur_2;
loop
fetch cur_2 into cust_id;
exit when cur_2%notfound;
NULL;
end loop;
close cur_2;
end;
--耗时48秒
2、隐式游标
declare
begin
for cur_2 in (select c.cust_name from ea_cust.cust_info c) loop
NULL;
end loop;
end;
--耗时16秒
3、bulk collect into + cursor
declare
cursor cur_3 is select a.cust_name from ea_cust.cust_info a;
type t_table is table of varchar2(100);
c_table t_table;
to_cust_id varchar2(100);
begin
open cur_3;
loop
fetch cur_3 bulk collect into c_table limit 100;
exit when c_table.count = 0;
for i in c_table.first..c_table.last loop
null;
end loop;
end loop;
commit;
end;
--耗时13秒,看样子这种最快
相关文章推荐
- 对300万一张表数据,用游标进行循环,不同写法的效率比较
- 对300万一张表数据,用游标进行循环,不同写法的效率比较
- 对300万一张表数据,用游标进行循环,不同写法的效率比较
- Java中迭代列表中数据时几种循环写法的效率比较
- Java中迭代列表中数据时几种循环写法的效率比较
- Oracle游标进行循环效率比较
- Java中迭代列表中数据时几种循环写法的效率比较
- oracle使用游标进行循环数据插入
- SQL 游标使用的小例子,对于每行数据根据参数的不同进行Insert或Update操作.
- Mysql模糊查询like效率,以及更高效的写法 在使用msyql进行模糊查询的时候,很自然的会用到like语句,通常情况下,在数据量小的时候,不容易看出查询的效率,但在数据量达到百万级,千万级的时
- 使用游标进行循环数据插入
- 关于qsort的比较函数的不同写法对于大数据造成的错误
- 按照网上的资料进行的百万级循环插入的效率分析循环插入数据库90万条数据的代码
- 使用SQL游标进行循环插入数据
- 比较Python 2 和 Python 3 在对list进行循环的执行效率
- [HighCharts] 关于对几组不同数量级的数据进行分类比较处理办法
- 使用SQL游标对数据进行遍历循环操作
- java连接数据库进行增添数据的不同写法
- 图像透明拷贝 - 不同方法的效率比较
- for循环写法带来的效率差异