WEB开发网
开发学院数据库MySQL MySQL分表优化试验 阅读

MySQL分表优化试验

 2009-01-05 11:15:43 来源:WEB开发网   
核心提示: 2、试验表,我们用一个有一千万条记录的表来做测试,MySQL分表优化试验(2),mysql> select count(*) from t_group;+--+| count(*) |+--+| 10388608 |+--+1 row in set (0.00 sec)表结构,mys

2、试验表。

我们用一个有一千万条记录的表来做测试。

mysql> select count(*) from t_group;
+----------+
| count(*) |
+----------+
| 10388608 |
+----------+
1 row in set (0.00 sec)

表结构。

mysql> desc t_group;
+-------------+------------------+------+-----+-------------------+----------------+
| Field    | Type       | Null | Key | Default      | Extra     |
+-------------+------------------+------+-----+-------------------+----------------+
| id     | int(10) unsigned | NO  | PRI | NULL       | auto_increment |
| money    | decimal(10,2)  | NO  |   |          |        |
| user_name  | varchar(20)   | NO  | MUL |          |        |
| create_time | timestamp    | NO  |   | CURRENT_TIMESTAMP |        |
+-------------+------------------+------+-----+-------------------+----------------+
4 rows in set (0.00 sec)

索引情况。

mysql> show index from t_group;
+---------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
|Table  | Non_unique | Key_name     | Seq_in_index | Column_name |Collation | Cardinality | Sub_part | Packed | Null | Index_type |Comment |
+---------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
|t_group |     0 | PRIMARY     |      1 | id     |A     |  10388608 |   NULL | NULL  |   | BTREE   |     |
| t_group |     1 | idx_user_name  |      1 | user_name  | A     |      8 |   NULL | NULL  |   |BTREE   |     |
| t_group |     1 | idx_combination1|      1 | user_name  | A     |      8 |   NULL |NULL  |   | BTREE   |     |
| t_group |     1 |idx_combination1 |      2 | money    | A     |    3776|   NULL | NULL  |   | BTREE   |     |
+---------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
4 rows in set (0.00 sec)

上一页  1 2 3 4 5  下一页

Tags:MySQL 分表 优化

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接