mysql中导入数据load data在myisam与innodb区别
发布:smiling 来源: PHP粉丝网 添加日期:2014-09-23 17:19:04 浏览: 评论:0
myisam与innodb存储引擎类型在数据上是有很大的区别的,今天我来给大家做一个测试用来测试load data导入数据在myisam与innodb类型存储引擎上的一些区别,希望例子能帮助各位带来帮助中.
innodb数据表结构如下,代码如下:
- Create Table: CREATE TABLE `tinnodb` (
- `id` int(11) DEFAULT NULL,
- `content` mediumtext
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
表中的数据为4194304行,通过select into outfile导出,代码如下:
- root@localhost:tiger>select * from tinnodb into outfile ‘/tmp/tiger_tinnodb.txt’ fields terminated by ‘,’ optionally enclosed by ‘”‘;
- Query OK, 4194304 rows affected (3.67 sec)
Myisam数据结构如下:
- Create Table: CREATE TABLE `tmyisam` (
- `id` int(11) DEFAULT NULL,
- `content` mediumtext
- ) ENGINE=myisam DEFAULT CHARSET=utf8
- root@localhost:tiger>show variables like 'innodb_flush_log_at_trx_commit';
- +--------------------------------+-------+
- | Variable_name | Value |
- +--------------------------------+-------+
- | innodb_flush_log_at_trx_commit | 1 |
- +--------------------------------+-------+
- 1 row in set (0.00 sec)
以下开始导入测试,导入到innodb数据表的结果如下:
- root@localhost:tiger>load data infile ‘/tmp/tiger_tinnodb.txt’ into table tinnodb fields terminated by ‘,’ optionally enclosed by ‘”‘;
- Query OK, 4194304 rows affected (58.37 sec)
- Records: 4194304 Deleted: 0 Skipped: 0 Warnings: 0
导入到myisam数据表的结果如下:
- root@localhost:tiger>load data infile ‘/tmp/tiger_tinnodb.txt’ into table tinnodb fields terminated by ‘,’ optionally enclosed by ‘”‘;
- Query OK, 4194304 rows affected (2.97 sec)
- Records: 4194304 Deleted: 0 Skipped: 0 Warnings: 0
通过初步的耗时来看,在批量导入这个方面myisam占不小的优势,现在调整innodb_flush_log_at_trx_commit重新做测试,代码如下:
- root@localhost:tiger>set global innodb_flush_log_at_trx_commit=2;
- Query OK, 0 rows affected (0.00 sec)
- root@localhost:tiger>show variables like 'innodb_flush_log_at_trx_commit';
- +--------------------------------+-------+
- | Variable_name | Value |
- +--------------------------------+-------+
- | innodb_flush_log_at_trx_commit | 2 |
- +--------------------------------+-------+
- 1 row in set (0.00 sec)
- root@localhost:tiger>load data infile ‘/tmp/tiger_tinnodb.txt’ into table tinnodb2 fields terminated by ‘,’ optionally enclosed by ‘”‘;
- Query OK, 4194304 rows affected (56.46 sec)
- Records: 4194304 Deleted: 0 Skipped: 0 Warnings: 0
- //开源代码phpfensi.com
这里没什么大的变化,若是与mysqldump所导出的.sql文件做比对导入的话,这个时间不是差一点点的,具体的可以自行测试下.
值得思考下,什么场景下可以通过select into outfile和load data infile来做局部的数据备份?毕竟load data infile还算挺高效的.
Tags: mysql导入数据 myisam innodb
相关文章
- ·mysql中常用命令导入导出数据命令(mysqldump,source)(2014-09-23)
- ·合理使用mysql中的load data infile导入数据(2014-09-25)
- ·MySQL数据导入导出实例教程手册(2014-09-27)
- ·MYSQL数据库的导出和导入方法详解(2014-10-04)
- ·mysql中导入数据与导出数据库sql语句(2014-10-09)
- ·mysql导入数据提示的MySQL server has gone away解决办法(2014-10-09)
- ·mysql导入数据库时出现40101错误解决方法(2014-10-10)
- ·mysql导入数据方法(txt,csv)(2014-10-13)
- ·mysql中导入较大数据简单实现代码(2014-10-13)
- ·MySQL中into outfile将导入数据到文件(2015-04-17)
- ·数据表是MyISAM格式,是什么意思?(2014-01-14)
- ·MySQL数据库MyISAM存储引擎转为Innodb(2014-10-02)
- ·MySQL myisamchk修复正在使用,无法访问数据表(2014-10-02)
- ·mysql数据库中MyISAM与InnoDB区别及性能详谈(2014-10-12)
- ·MyISAM和InnoDB不同与优化方法(2014-10-14)
- ·MySQL MyISAM 转 Innodb(2014-10-17)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)