最初安装mysql时,用的是开发者模式,内存开的比较小,后面又配置一下,内存开大了,看看效果。
my.ini里有区别的配置:
配置项 | 修改后 | 原值 |
tmp_table_size | 179 | 17 |
myisam_sort_buffer_size | 357 | 34 |
key_buffer_size | 308 | 25 |
innodb_additional_mem_pool_size | 13 | 2 |
innodb_log_buffer_size | 7 | 1 |
innodb_buffer_pool_size | 597 | 46 |
====================================================================================
重新配置了mysql,开大了各个内存。
创建索引,一千万数据,两列复合索引,用时23分钟左右。
原来要1.5小时左右。
mysql> alter table tb_2 add index last_first (lastName,firstName);
Query OK, 10000000 rows affected (23 min 40.20 sec)
Records: 10000000 Duplicates: 0 Warnings: 0
====================================================================================
mysql> select * from tb_2 where birthday='2000-02-29';
250 rows in set (10.53 sec)
mysql> select * from tb_2 where birthday='2000-02-29';
247 rows in set (6.86 sec)
mysql> select * from tb_2 where birthday='1908-01-29';
252 rows in set (6.81 sec)
重新配置了mysql,开大了各个内存。对birthday索引,用时26分钟左右。
原来要3.5个小时。不过这里的数据是排过序的。
mysql> create index birthdayIndex on tb_2 (birthday);
Query OK, 10000000 rows affected (25 min 59.08 sec)
Records: 10000000 Duplicates: 0 Warnings: 0
索引后提速几百倍。
mysql> select * from tb_2 where birthday='2000-02-29';
250 rows in set (0.00 sec)
mysql> select * from tb_2 where birthday='1908-01-29';
252 rows in set (0.03 sec)
mysql> select * from tb_2 where birthday='1908-01-29';
252 rows in set (0.00 sec)
====================================================================================
修改配置后,生成索引的速度提升明显。