数据库中如何实现大量数据快速插入方法
发表于:2024-10-08 作者:千家信息网编辑
千家信息网最后更新 2024年10月08日,这篇文章将为大家详细讲解有关数据库中如何实现大量数据快速插入方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。1 环境搭建构建一个千万级别的源表,向一个空表inse
千家信息网最后更新 2024年10月08日数据库中如何实现大量数据快速插入方法
这篇文章将为大家详细讲解有关数据库中如何实现大量数据快速插入方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1 环境搭建
构建一个千万级别的源表,向一个空表insert操作。
参考指标:insert动作完成的实际时间。
SQL> drop table test_emp cascadeconstraints purge;Table dropped.SQL> create table test_emp as select *from emp;Table created.SQL> begin 2 for i in 1..10 loop 3 insert into test_emp select *from test_emp; --批量dml,建议forall 4 end loop; 5 end; 6 /PL/SQL procedure successfully completed.SQL> select count(*) from test_emp; COUNT(*)---------- 14336SQL> begin 2 for i in 1..10 loop 3 insert into test_emp select *from test_emp; 4 end loop 5 ; 6 end; 7 /PL/SQL procedure successfully completed.SQL> select count(*) from test_emp; COUNT(*)---------- 14680064 --1.5千万级别
2 only append
SQL> set timing onSQL> show timingtiming ONSQL> insert /*+ append */ into test_goalselect * from test_emp;14680064 rows created.
Elapsed: 00:00:20.72
没有关闭日志,所以时间是最长的。
3 append+nologging
SQL> truncate table test_goal;Table truncated.Elapsed: 00:00:00.11SQL> insert /*+ append */ into test_goalselect * from test_emp nologging;14680064 rows created.
Elapsed: 00:00:04.82
发现日志对插入的影响很大,加nologging时间明显大幅缩短;当然这个表没有索引、约束等,这里暂不考究。
4 append+nologging+parallel
SQL> truncate table test_goal;Table truncated. Elapsed: 00:00:00.09SQL> insert /*+ parallel(2) append */into test_goal select * from test_emp nologging;14680064 rows created.
Elapsed: 00:00:02.86
这里在3的基础上加上并行,性能基本达到极限,1.5千万数据插入时间控制在3S左右。并行在服务器性能支持的情况下,可以加大并行参数。
关于"数据库中如何实现大量数据快速插入方法"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
数据
时间
篇文章
数据库
方法
性能
日志
更多
级别
参考
不错
实用
很大
明显
最长
内容
动作
参数
基础
实际
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
青浦区互联网软件开发代理价格
网众服务器修改ip
服务器作为数据中心的核心设备
金山区优势软件开发费用
判断sql数据库
服务器安全狗安装服务名
浙江运营网络技术哪家便宜
职工管理系统数据库课程设计总结
数据库管理技术发展顺序
2020年网络安全为人民
上海市公安人口数据库
gt7无法与服务器维护
续签软件开发合同
ssh清空表数据库
警察网络安全课件ppt图片
天津曙光服务器虚拟化安装
肥东综合网络技术咨询怎么样
国家大数据库
常用的中文文献检索数据库有
blued app 软件开发
阜阳有哪些软件开发学校
广州哪里软件开发培训学校好
大连东软软件开发怎样
肇庆市网络安全信息化委员会
森林固碳数据库
数据库网页查询系统源码
计算机网络技术里的名词解释
洛阳博发软件开发
我的电脑登不上局域网服务器
金蝶软件数据库oracle