1.一些错误情况 数据库表中添加索引后确实会让查询速度起飞,但前提必须是正确的使用索引来查询,如果以错误的方式使用,则即使建立索引也会不奏效。即使建立索引,索引也不会生效: 2.其他注意事项 - 避免使用select * - count(1)或count(列) 代替 count(*) - 创建表时尽 Read More
explain SQL; 在sql语句前面加explain实现“执行计划”的功能。功能是比较准确的显示将要执行这条sql语句的运行状况。 select_simple 是查询类型;table 表名字 possible_keys,key 有可能,真实走的那一列索引 rows 涉及多少条数据 在上述的图片 Read More
1.关于索引 # 什么是索引 索引是表的目录,在查找内容之前可以先在目录中查找索引位置,以此快速定位查询数据。 #索引的作用 加速查询和约束。 # 为什么索引查询会变快 没创建一个索引会相应的创建一个索引表。索引表是由相应的数据和B-tree数字组成: 30 10 40 5 15 35 66 1 6 Read More