数据库|mysql教程
Mysql,查询,语句,中引号,索引,影响,explai
数据库-mysql教程
php空间销售系统源码,vscode调试附加进程,ubuntu进入dos,tomcat部署名称,爬虫 生成cookies,php 变量名称,常州seo外包哪里有公司,电商网站开源模板,v10x站模板lzw
# explain select * from t1 where user_ip=123 limit 1;——————————————————————————————-| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |——-
o2o门店商城源码,vscode配置的版本,ubuntu执行 sh,tomcat发布栈溢出,爬虫传媒,微信cms 开源php,济南seo哪家价格低,h5 php网站源码,仿秀站网织梦模板下载lzw
网络游戏辅助源码,vscode代码关键字变色,ubuntu 系统汉化,tomcat 性能如何设置,bot爬虫软件,php原生sql查询,巩义seo技术培训班lzw
# explain select * from t1 where user_ip=123 limit 1;+----+-------------+-------------+------+---------------+------+---------+------+------+-------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------------+------+---------------+------+---------+------+------+-------------+| 1 | SIMPLE| t1 | ALL | user_ip | NULL | NULL | NULL | 262 | Using where |+----+-------------+-------------+------+---------------+------+---------+------+------+-------------+1 row in set (0.00 sec)# explain select * from t1 where user_ip=123 limit 1;+----+-------------+-------------+------+---------------+---------+---------+-------+------+-------------+| id | select_type | table | type | possible_keys | key| key_len | ref | rows | Extra |+----+-------------+-------------+------+---------------+---------+---------+-------+------+-------------+| 1 | SIMPLE| t1 | ref | user_ip | user_ip | 47| const | 1 | Using where |+----+-------------+-------------+------+---------------+---------+---------+-------+------+-------------+1 row in set (0.01 sec)
可以看到, user_ip 字段是 varchar 类型. 查询时, 如果这个字段的值没有加引号, MySQL 就不会使用索引. MySQL 为什么会有这种致命的策略?!
—– 更新: —–
相关的文档已经找到: /doc/refman/5.5/en/type-conversion.html,
这里面提到和几种类型转换的情况, 字符串和数字比较都被统一转成浮点数再比较.
Related posts:
MySQL”海量数据”查询性能分析MySQL 查询使用 Group By 的注意点史上最强大的PHP MySQL操作类MySQL 建立外键约束如何使用SSDB的zscan命令