zoukankan      html  css  js  c++  java
  • 5.6中使用字符串存放时间,导致隐式转换发生的记录

    CREATE TABLE `test_date` (

      `id` int(11) DEFAULT NULL,

      `gmt_create` varchar(100) DEFAULT NULL,

      KEY `ind_gmt_create` (`gmt_create`)

    ) ENGINE=InnoDB AUTO_INCREMENT=524272;

    5.5:

    mysql> explain  select * from test_date where gmt_create BETWEEN DATE_ADD(NOW(), INTERVAL - 1 MINUTE) AND        DATE_ADD(NOW(), INTERVAL 15 MINUTE) ;

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

    | id | select_type | table     | type  | possible_keys  | key            | key_len | ref  | rows | Extra       |

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

    |  1 | SIMPLE      | test_date | range | ind_gmt_create | ind_gmt_create | 303     | NULL |    1 | Using where |

    5.6:

    mysql> explain select * from test_date where gmt_create BETWEEN DATE_ADD(NOW(), INTERVAL - 1 MINUTE) AND        DATE_ADD(NOW(), INTERVAL 15 MINUTE) ; 

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

    | id | select_type | table     | type | possible_keys  | key  | key_len | ref  | rows    | Extra       |

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

    |  1 | SIMPLE      | test_date | ALL  | ind_gmt_create | NULL | NULL    | NULL | 2849555 | Using where |

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

    | Warning | 1739 | Cannot use range access on index 'ind_gmt_create' due to type or collation conversion on field 'gmt_create'      

  • 相关阅读:
    linq to entity之字符串比较
    linq to entity 分页方法不支持LastOrDefault等操作的处理办法
    easyui蛋疼之二 tabs与accordion
    根据下拉框生成控件列表
    第一个flash AS代码
    250多个Jquery各式各样的插件
    对用户控件的访问方式重写
    WP7之Slider绑定textblock设置字体大小
    辉南三角龙湾
    回到正轨
  • 原文地址:https://www.cnblogs.com/yuyue2014/p/5195263.html
Copyright © 2011-2022 走看看