mysql多列分区表,查询只使用第二个字段是否能自动分区裁剪测试
2017-08-21 11:53
453 查看
CREATE TABLE `tb2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userid` int(11) DEFAULT NULL, `name` varchar(20) not null, `birthday` date DEFAULT NULL, PRIMARY KEY (id,name), KEY `idx_name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 PARTITION BY RANGE COLUMNS(id,name) ( PARTITION p1 VALUES LESS THAN(1000,'ab'), PARTITION p2 VALUES LESS THAN(10000,'ef'), PARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE));
向tb2里面插入一些测试数据
mysql> SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'tb2'; +----------------+------------+ | PARTITION_NAME | TABLE_ROWS | +----------------+------------+ | p1 | 996 | | p2 | 9000 | | p3 | 204907 | +----------------+------------+ 3 rows in set (0.00 sec) mysql> explain partitions select count(*) from tb2 where id=2; +----+-------------+-------+------------+------+---------------+---------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+------+---------------+---------+---------+-------+------+----------+-------------+ | 1 | SIMPLE | tb2 | p1 | ref | PRIMARY | PRIMARY | 4 | const | 1 | 100.00 | Using index | +----+-------------+-------+------------+------+---------------+---------+---------+-------+------+----------+-------------+ 1 row in set, 2 warnings (0.00 sec) mysql> select * from tb2 where id=2; +----+--------+------------+------------+ | id | userid | name | birthday | +----+--------+------------+------------+ | 2 | 144834 | UjnoZmAncn | 1988-11-03 | +----+--------+------------+------------+ 1 row in set (0.00 sec) mysql> explain partitions select count(*) from tb2 where name='UjnoZmAncn'; +----+-------------+-------+------------+------+---------------+----------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+------+---------------+----------+---------+-------+------+----------+-------------+ | 1 | SIMPLE | tb2 | p1,p2,p3 | ref | idx_name | idx_name | 62 | const | 1 | 100.00 | Using index | +----+-------------+-------+------------+------+---------------+----------+---------+-------+------+----------+-------------+ 1 row in set, 2 warnings (0.00 sec) mysql> select count(*) from tb2 where name='UjnoZmAncn'; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec)
看到只是根据分区字段的第二个字段查询是无法做到自动分区裁剪的。
相关文章推荐
- mysql 查看查询时如何分区是否被使用
- ORACLE分区表的查询(使用分区键查询自动默认)
- Mysql使用Describe命令判断字段是否存在
- MySQL 分区表 partition线上修改分区字段,后续进一步学习partition (2) --> 子分区以及对录入Null值的处理情况.
- mysql使用教程之分区表的使用方法(删除分区表)
- mysql 使用rand随机查询记录效率测试
- MySQL 5.5 分区性能测试之索引使用情况
- mysql如何把查询到的数据加上一个自动编号字段
- (摘)mysql使用rand随机查询记录效率测试
- MySQL 分区表 partition线上修改分区字段,后续进一步学习partition (1)
- MySQL 5.5 分区性能测试之索引使用情况
- mysql中使date字段使用默认值(即当前时间)自动添加
- mysql使用教程之分区表的使用方法(删除分区表)
- MySQL 分区表 partition线上修改分区字段,后续进一步学习partition (1)
- mysql使用rand随机查询记录效率测试
- MySQL使用rand随机查询记录效率测试
- mysql使用rand随机查询记录效率测试
- mysql 使用rand随机查询记录效率测试
- Oracle模糊查询之(2.如何测试模糊查询的时间及使用是否使用索引)反向索引与模糊查询
- mysql使用rand随机查询记录效率测试 【转】