当 where 查询条件左右两侧类型不匹配的时候会发生隐式转换,隐式转换可能带来的不好影响就是导致索引失效而进行全表扫描。
下面的案例中,brith_date 是字符串,然而匹配的是整数类型,从而发生隐式转换。
```mysql
select from users where brith_date = 19950610;
```
### 11. like 语句的索引失效问题
当我们使用 like “value%” 的方式时是会使用索引的,但是对于 like “%value%” 这样的方式,必定会执行全表查询,这在数据量小的表,不存在性能问题,但是对于海量数据,全表扫描是非常可怕的事情。所以,根据业务需求,考虑使用 ElasticSearch 或 Solr 是个不错的方案。
## 重构查询方式
### 1. 切分大查询
...
...
@@ -483,5 +425,3 @@ MySQL 读写分离能提高性能的原因在于:
-[How to create unique row ID in sharded databases?](https://stackoverflow.com/questions/788829/how-to-create-unique-row-id-in-sharded-databases)
-[SQL Azure Federation – Introduction](http://geekswithblogs.net/shaunxu/archive/2012/01/07/sql-azure-federation-ndash-introduction.aspx"Title of this entry.")