游戏开发论坛

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: cndv3996

MySQL有关insert大量数据的问题(百万行)

[复制链接]

6

主题

141

帖子

822

积分

高级会员

Rank: 4

积分
822
发表于 2016-5-20 14:59:27 | 显示全部楼层
简单的说,按我的写法,执行语句就2条,而你要10000条

6

主题

141

帖子

822

积分

高级会员

Rank: 4

积分
822
发表于 2016-5-20 15:35:46 | 显示全部楼层
先把临时表建好res_type_collect
Load Data InFile 'D:/1.txt' Into Table `res_type_collect` fields terminated by ',' lines terminated by '\n';

insert into mis_table_data_list (test_id, test_data) select a.test_id,b.test_data from mis_table_test_info a, res_type_collect b where a.test_name = b.test_name

我这样写的话估计可以快10倍,(当我说大话)

31

主题

257

帖子

1752

积分

金牌会员

申城谍影

Rank: 6Rank: 6

积分
1752
QQ
 楼主| 发表于 2016-5-20 15:46:16 | 显示全部楼层
握紧拳头 发表于 2016-5-20 15:35
先把临时表建好res_type_collect
Load Data InFile 'D:/1.txt' Into Table `res_type_collect` fields term ...

好像是个好办法。。。。。。。。

我试试,谢谢

31

主题

257

帖子

1752

积分

金牌会员

申城谍影

Rank: 6Rank: 6

积分
1752
QQ
 楼主| 发表于 2016-6-3 10:21:11 | 显示全部楼层
握紧拳头 发表于 2016-5-20 15:35
先把临时表建好res_type_collect
Load Data InFile 'D:/1.txt' Into Table `res_type_collect` fields term ...

用你建议的方法,

同样的数据,原来要25分钟,
现在大概6分钟。。。

因为数据结构的问题,迭代次数有点多,
要是想办减少迭代次数,

感觉时间还能减少。。。。。
谢谢你了。。。。。。。。。。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2024-5-20 07:10

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表