0
我使用partition plugin ACTIVE運行MySQL 5.1.47。MySQL分區:分區中的數據不平衡
我創建下表:
CREATE TABLE IF NOT EXISTS `prova` (
`NE` varchar(8) NOT NULL,
`ASSERT` longtext NOT NULL
) ENGINE=MyISAM
PARTITION BY KEY(NE)
PARTITIONS 4;
然後我插入4行:
INSERT INTO prova values ('AAA','this assert is from AAA');
INSERT INTO prova values ('BBB','this assert is from BBB');
INSERT INTO prova values ('CCC','this assert is from CCC');
INSERT INTO prova values ('DDD','this assert is from DDD');
我希望找到在每個分區1分的紀錄,但:
mysql> explain partitions select * from prova where NE='AAA';
+----+-------------+-------+------------+--------+---------------+------+---------+------+------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------------+--------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | prova | p2 | system | NULL | NULL | NULL | NULL | 1 | |
+----+-------------+-------+------------+--------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)
mysql> explain partitions select * from prova where NE='BBB';
+---+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | prova | p1 | ALL | NULL | NULL | NULL | NULL | 4 | Using where |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
mysql> explain partitions select * from prova where NE='CCC';
+----+-------------+-------+------------+--------+---------------+------+---------+------+------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------------+--------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | prova | p0 | system | NULL | NULL | NULL | NULL | 1 | |
+----+-------------+-------+------------+--------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)
mysql> explain partitions select * from prova where NE='DDD';
+----+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | prova | p1 | ALL | NULL | NULL | NULL | NULL | 4 | Using where |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
所以,我的問題是: 我做錯了什麼?爲什麼4插入不分割成4個分區? 爲什麼BBB和DDD進入同一個分區?
非常感謝您的幫助! Evan)
我剛剛發現,如果我使用A,B,C,D而不是AAA,BBB,CCC,DDD分區工作正常。你能否建議如何根據字符串分割表而不是單個字符?謝謝!!! – EBAH