The following environments are:
Software:
HOST: winxp sp3
Virtual Machine Software: wmware ws 7.1
Virtual Machine System: rhel5.1 + mysql5.157
Host hardware:
Cpu: Core 2 T8100
Memory: 3 GB
- Mysql> desc t;
- + ----------------- + ------------------- + ------ + ----- + --------- + ------- +
- | Field | Type | Null | Key | Default | Extra |
- + ----------------- + ------------------- + ------ + ----- + --------- + ------- +
- | TABLE_CATALOG | varchar (512) | YES | NULL |
- | TABLE_SCHEMA | varchar (64) | NO | NULL |
- | TABLE_NAME | varchar (64) | NO | NULL |
- | TABLE_TYPE | varchar (64) | NO | NULL |
- | ENGINE | varchar (64) | YES | NULL |
- | VERSION | bigint (21) unsigned | YES | NULL |
- | ROW_FORMAT | varchar (10) | YES | NULL |
- | TABLE_ROWS | bigint (21) unsigned | YES | NULL |
- | AVG_ROW_LENGTH | bigint (21) unsigned | YES | NULL |
- | DATA_LENGTH | bigint (21) unsigned | YES | NULL |
- | MAX_DATA_LENGTH | bigint (21) unsigned | YES | NULL |
- | INDEX_LENGTH | bigint (21) unsigned | YES | NULL |
- | DATA_FREE | bigint (21) unsigned | YES | NULL |
- | AUTO_INCREMENT | bigint (21) unsigned | YES | NULL |
- | CREATE_TIME | datetime | YES | NULL |
- | UPDATE_TIME | datetime | YES | NULL |
- | CHECK_TIME | datetime | YES | NULL |
- | TABLE_COLLATION | varchar (32) | YES | NULL |
- | CHECKSUM | bigint (21) unsigned | YES | NULL |
- | CREATE_OPTIONS | varchar (255) | YES | NULL |
- | TABLE_COMMENT | varchar (80) | NO | NULL |
- + ----------------- + ------------------- + ------ + ----- + --------- + ------- +
- 21 rows in set (0.04 sec)
- Mysql> select count (*) from t;
- + ---------- +
- | Count (*) |
- + ---------- +
- | 1, 502564 |
- + ---------- +
- 1 row in set (0.00 sec)
- Mysql> select * from t into outfile'/Tmp/t.txt'Fields terminated','Enclosed'"';
- Query OK, 502564 rows affected (5.09 sec)
- Mysql> create table t1 select * from t where 1 <> 1;
- Query OK, 0 rows affected (0.02 sec)
- Records: 0 Duplicates: 0 Warnings: 0
- Mysql> select * from t1;
- Empty set (0.01 sec)
- Mysql> load data infile'/Tmp/t.txt'Into table t1 fields terminated','Enclosed'"';
- Query OK, 502564 rows affected (8.73 sec)
- Records: 502564 Deleted: 0 Skipped: 0 Warnings: 0
- Mysql> select count (*) from t;
- + ---------- +
- | Count (*) |
- + ---------- +
- | 1, 502564 |
- + ---------- +
- 1 row in set (0.00 sec)
- Mysql> select count (*) from t1;
- + ---------- +
- | Count (*) |
- + ---------- +
- | 1, 502564 |
- + ---------- +
- 1 row in set (0.00 sec)
- Mysql>
Figure 1 use information_schema.tables to generate the test table t.
- [Root @ rhel5 ~ 05:04:56] # ll-h/tmp
- Total 88 M
- -Rw-1 mysql 80 Sep 21 16:16 a.txt
- Drwx ------ 2 root 4.0 K Feb 18 2015 keyring-mViyDu
- Srwxr-xr-x 1 Oracle oinstall 0 Aug 3 2010 mapping-oracle
- Srwxr-xr-x 1 root 0 Feb 18 2015 mapping-root
- -Rw ---- 1 mysql 2.8 K Sep 21 16:56 mysqlslow. log
- Srwxrwxrwx 1 mysql 0 Sep 21 :17 mysql. sock
- Srw ------- 1 oracle oinstall 0 Aug 3 2010 scim-panel-socket: 0-oracle
- Srw ------- 1 root 0 Feb 18 2015 scim-panel-socket: 0-root
- Drwx ------ 2 root 4.0 K Sep 21 ssh-kahSRu6355
- Drwx ------ 2 root 4.0 K Sep 21 ssh-XCGOuG6217
- -Rw-1 mysql 88 M Sep 21 :01 t.txt
Figure 2 Tsung data file of the test table is t.txt
The test procedure is as follows:
USE insert into t select * from t; insert data until the number of records is 0.5 million.
Then, import t data to a text file.
Use the loaddata command to import data from a text file to table t2.
The operation time has been shown in the figure, and the speed is much faster than I expected!