MyCATApache / Mycat2

MySQL Proxy using Java NIO based on Sharding SQL,Calcite ,simple and fast
http://www.mycat.org.cn/
GNU General Public License v3.0
1.7k stars 478 forks source link

做了个最简单的自然月分片,但是explain 执行语句的时候,却是全表扫,那就没有达到分表的目的了 #589

Closed dualven closed 3 years ago

dualven commented 3 years ago

Describe the bug

To Reproduce Steps to reproduce the behavior: image

explain select * from mesh_info_topo where create_time > "2021-10-01 00:00:00" and create_time < "2021-10-02 00:00:00";

image 只有=的精确查询,才是路由到一张表,这有啥用呢,我们一般用的都是范围查询啊 image

junwen12221 commented 3 years ago

用规则分片 https://www.yuque.com/ccazhw/ml3nkf/518d1c41faf01cca8f4544f0c6ee5d6e

dualven commented 3 years ago

那么,这种mycat2的路由算法 ,在查询的时候,一般都是范围查询,那么mycat2的路由算法 的优势 与作用在哪,一查询就会全表查询。。。。。

junwen12221 commented 3 years ago

比如这个

   "function":{
        "clazz": "io.mycat.router.mycat1xfunction.PartitionByMonth",
        "name": "PartitionByMonth",
        "properties": {
          "dateFormat": "yyyy-MM-dd hh:mm:ss",
          "beginDate": "2021-01-01 00:00:00",
          "endDate": "",
          "columnName": "create_time"
        },
        "ranges":{}
      },

就支持范围查询

mycat2默认的hash算法是与云上DRDS,比如华为DDM和阿里云PolarDB-X数据库一致的,一般来说,hash算法不支持范围查询,对于一些情况是可以范围查询的,但是现在没有实现.

junwen12221 commented 3 years ago

业务查询SQL的使用方式,是看系统怎么设计的,mycat是尽可能都支持,自动分片,自定义分片,根据不同的算法特性支持分区剪裁.