MySQL optimization--100 million data efficiency COUNT(*)

Recently, I found a Mysql fast data import method load data infile, please refer to http://www.taobaodba.com/html/558_loaddata.html, this article for details.
Here are a few commands to show you the efficiency results.
To put it simply:
1.txt, there was only 100,000 data at the beginning, and then added to 20 million lines with vim, and the editor under Windows was directly stuck, and Gvim was installed under Windows.
The data table type is Innodb, without any index optimization.
1. It takes less than 1 second to import 100,000 rows of records
mysql> load data infile './1.txt' into table article (keywords);
Query OK, 107200 rows affected (0.96 sec)
Records: 107200 Deleted: 0 Skipped: 0 Warnings : 0
2. Import 20 million rows of data
mysql> load data infile './1.txt' into table article (
Query OK, 20000000 rows affected (5 min 53.02 sec)
Records: 20000000 Deleted: 0 Skipped: 0 Warnings: 0
3. Statistical data in 90 million, pay attention to the comparison with the fourth
mysql> select count(id) from article;
+------------+
| count(id) |
+-----------+
| 92893775 |
+-----------+
1 row in set (1 min 28.86 sec)
4. Query 110 million data, which is significantly longer than the previous one.
mysql> select count(id) from article ;
+-----------+
| count(id) |
+-----------+
| 112893775 |
+---- -------+
1 row in set (5 min 18.83 sec)
5. Using count(*) reduces the time by about 25 seconds.
mysql> select count(*) from article ;
+-----------+
| count(*) |
+-----------+
| 112893775 |
+---- -------+
1 row in set (4 min 5.53 sec)
6. Use count(1) to save 1 minute and 40 seconds
mysql> select count(1) from article ;
+-------- ---+
| count(1) |
+-----------+
| 112893775 |
+-----------+
1 row in set (3 min 36.59 sec)
March 19, 2011 Added new test
MYISAM engine

mysql> select count(1) from test;
+-----------+
| count(1) |
+-----------+
| 326039962 |
+------------+
1 row in set (0.08 sec) is
too much, I won't say it, let's see the result.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326691257&siteId=291194637