现在情况是这样的。
1、当我不设置分区,直接设置primary key , 然后插入12条数据,  explain select * from em where id =1; 
结果是这样的------+-------+
| id | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
|  1 | SIMPLE      | em    | const | PRIMARY       | PRIMARY | 4       | const |    1 |       |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
2、当我设置分区,也设置了primary key,然后插入12条数据, explain select * from em where id =1; 
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
|  1 | SIMPLE      | em    | const | PRIMARY       | PRIMARY | 4       | const |    1 |       |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
一个完全相同的结果,这事不是表示分区表并未起到作用?

解决方案 »

  1.   

    然后我尝试不设置primary key,希望在分区之后,插入数据以后建立local index
    1、我的创建表语句create table em (id int, text varchar(20)) partition by hash(id%10) partitions 3;
    2、我尝试create local index, create index id1 on em(id) local;  提示local出错
    急求问大神们,这种建立本地索引应该如何做?
      

  2.   

    参考:http://blog.itpub.net/26230597/viewspace-767227/