失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 关于mysql使用存储过程插入大量数据的问题

关于mysql使用存储过程插入大量数据的问题

时间:2019-02-26 09:21:22

相关推荐

关于mysql使用存储过程插入大量数据的问题

数据库|mysql教程

mysql

大量数据

插入

存储过程

数据库-mysql教程

mysql大量数据插入存储过程

网狐 源码 编译,vscode将字母转化为大写,ubuntu arm64,tomcat怎么配置限流,sqlite列复制,佛山禅城网页设计,服务器网站搬家,js 饼图插件,前端uni框架,爬虫西斜,php验签,北京seo服务商,springboot事务锁死,网站模板没有html文件下载,网页模板电商,h5企业介绍模板,phpcms修改后台的封面,html页面布局 表单布局,学生管理系统vb程序设计,gabor特征提取程序lzw

创建数据库

create database ceshi;

use ceshi;

创建表

create table ce(

id int not null auto_increment,

name varchar(50) default null,

pw char(50),

primary key(id));

qq红包网页源码,pop3 ubuntu,tomcat数据源歇菜,爬虫族帝国,php数据关联,渝北专业的seo优化哪家好lzw

存储过程

delimiter //

create procedure insert_ce(in item int)

begin

declare counter int;

declare i int;

set counter=item;

while counter >=1 do

insert into ce values(counter,concat(‘mysqls’,counter),repeat(‘ab’,5));

set counter =counter-1;

set i=i+1;

if i=1000 then

set i=0;

commit;

end if;

end while;

end

//

delimiter ;

十万条数据使用的时间是40分钟

基于asp的工资管理系统源码,vscode里的括号颜色,重启网卡ubuntu,修改tomcat监听地址,反爬虫保护,php实用函数,郑州电商平台seo优化,网站qq客服制作,网页css代码模板lzw

另一钟方法:

create table t_2 (id serial,name char(5)) ;

delimiter $$

SET AUTOCOMMIT = 0$$

create procedure test02(in i int)

begin

declare v_cnt decimal (10) default 0 ;

dd:loop

insert into t_2 values

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’),

(null,’aaaaa’);

commit;

set v_cnt = v_cnt+10 ;

if v_cnt = i then leave dd;

end if;

end loop dd ;

end;$$

delimiter ;

十万条数据使用的时间是7分钟

设置缓存的话不到两种方法都是一份钟不到就好了,朋友说有可能是默认缓存过小的原因。可是,两种方法在同一个机子上测试,没有设置缓存,所用的时间就是差很多。

想问一下是什么原因造成的,还想知道插入多少条数据提交一次才是最优插入,第二种方法的注释?

如果觉得《关于mysql使用存储过程插入大量数据的问题》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。