• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

mysql安插1亿条数据要多长时间

mysql 搞代码 7年前 (2018-06-04) 122次浏览 已收录 0个评论

mysql插入1亿条数据要多长时间?

@Test      public void insert1000Data(){         try {             String sql = "insert into usersss(name,descn)values(' 很郁闷 ',' 嘻嘻哈哈好嘻嘻哈哈好 ')" ;             conn .setAutoCommit( false );             long start = System.currentTimeMillis ();             for ( int x=0;x<10000;x++){                Statement stmt = conn .createStatement();                for ( int i=0;i<10000;i++){                    stmt.execute(sql);                }                conn .commit();             }                         System. out .println(System.currentTimeMillis ()-start);          } catch (SQLException e) {             e.printStackTrace();         }      }  

欢迎大家阅读mysql安插1亿条数据要多长时间》,跪求各位点评,by 搞代码

 

Create table usersss(  id int primary key auto_increment,  name varchar(20),  descn varchar(20)  )    

 

 

1 个多小时 插入了 26310000 条记录。

 

Select count(*) from usersss    耗时 33.7s

Select count(id) from usersss    耗时 33.3s

 

Delete from usersss               耗时 6m 33s

 

 

本机配置:

Cup:T7500

内存: 3G

硬盘: 160G 5400r/m

 

软件环境:

Mysql: Server version: 5.0.41-community-nt MySQL Community Edition (GPL)

Windows XP 32 sp3

 

整个执行过程中 cup 占用 55% 左右, javaw 占用 18% 左右, mysql-nt.exe 占用 20% 左右。

插入时其他程序可正常运行,相互感觉没有影响速度。

26310000 条记录占用磁盘空间 2 个多 G delete 掉后释放了 1 G 的空间。(为什么还有 1 个多 G 不给释放?)

1 楼 yisafe 2009-06-28  
mysql安插1亿条数据要多长时间 很有趣的实验,没玩过。
2 楼 xieye 2009-06-28  
用linux再试,一定快很多
3 楼 txy920 2009-06-28  
改天一定在linux上测试一下,在window上给我郁闷坏了。
说明一下
jdbc驱动为:mysql-connector-java-5.0.4-bin.jar

表信息为:

+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+-------------------------+ | Name    | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation       | Checksum | Create_options | Comment                 | +---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+-------------------------+ | usersss | InnoDB |      10 | Compact    |    0 |              0 |       16384 |               0 |            0 |         0 |              1 | 2009-06-27 12:47:24 | NULL        | NULL       | utf8_general_ci |     NULL |                | InnoDB free: 2784256 kB | +---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+-------------------------+
4 楼 xucz153 2009-07-01  
楼主再帖帖linux下怎么测试呀?还是用java来测试吗?SHELL可不可以做到呀?或者PERL
5 楼 maomiandyou 2010-03-24  
闲的…

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:mysql安插1亿条数据要多长时间

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址