您现在的位置:主页 > 技术中心 > 数据库技术 > Mysql

mysql水平分表和垂直分表和数据库分区(4)

来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:36 点击:

 

+----------+

 

| count(*) |

 

+----------+

 

|   795181 |

 

+----------+

 

1 row in set (38.30 sec)

 

mysql> select count(*) from part_tab where

 

    -> c3 > date '1995-01-01' and c3 < date '1995-12-31';

 

+----------+

 

| count(*) |

 

+----------+

 

|   795181 |

 

+----------+

 

1 row in set (3.88 sec)

 

mysql> explain select count(*) from no_part_tab where

 

    -> c3 > date '1995-01-01' and c3 < date '1995-12-31'\G

 

*************************** 1. row ***************************

 

           id: 1

 

 select_type: SIMPLE

 

        table: no_part_tab

 

         type: ALL

 

possible_keys: NULL

 

          key: NULL

 

      key_len: NULL

 

          ref: NULL

 

         rows: 8000000

 

        Extra: Using where

 

1 row in set (0.00 sec)

 

mysql> explain partitions select count(*) from part_tab where

 

    -> c3 > date '1995-01-01' and c3 < date '1995-12-31'\G

 

*************************** 1. row ***************************

 

           id: 1

 

 select_type: SIMPLE

 

        table: part_tab

 

   partitions: p1

 

         type: ALL

 

possible_keys: NULL

 

          key: NULL

 

      key_len: NULL

 

          ref: NULL

 

         rows: 798458

 

        Extra: Using where

 

1 row in set (0.00 sec)

 

从上面结果可以容易看出,设计恰当表分区能比非分区的减少90%的响应时间。而命令解析Explain程序也告诉我们在对已分区的表的查询过程中仅对第一个分区进行了扫描,其他都跳过了。

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片

推荐热点

  • mysql-mmm
  • mysqldump命令——MySQL数据库备份还原
  • Oracle数据导入MySQL的快捷工具:MySQL Migration Tool
  • 简简单单储存过程——循环一个select结果集
  • MySQL数据库十大优化技巧
  • Mysql安装笔记
  • Mysql主主复制架构配置
  • Mysql的Procedure 参数为NULL问题分析
  • MySQL Stmt预处理提高效率问题的小研究
?? - ?? - ÝřŝžľŘÝź - TAGąęÇŠ - RSSśŠÔÄ - ??
Copyright © 2004-2024 上海卓卓网络科技有限公司