https://dev.mysql.com/doc/refman/8.0/en/statement-optimization.html

8.2 Optimizing SQL Statements

The core logic of a database application is performed through SQL statements, whether issued directly through an interpreter or submitted behind the scenes through an API. The tuning guidelines in this section help to speed up all kinds of MySQL applications. The guidelines cover SQL operations that read and write data, the behind-the-scenes overhead for SQL operations in general, and operations used in specific scenarios such as database monitoring.

其中,mysql如何避免全表扫描:

https://dev.mysql.com/doc/refman/8.0/en/table-scan-avoidance.html

8.2.1.21 Avoiding Full Table Scans

The output from EXPLAIN shows ALL in the type column when MySQL uses a full table scan to resolve a query. This usually happens under the following conditions:

  • The table is so small that it is faster to perform a table scan than to bother with a key lookup. This is common for tables with fewer than 10 rows and a short row length.

  • There are no usable restrictions in the ON or WHERE clause for indexed columns.

  • You are comparing indexed columns with constant values and MySQL has calculated (based on the index tree) that the constants cover too large a part of the table and that a table scan would be faster. See Section 8.2.1.1, “WHERE Clause Optimization”.

  • You are using a key with low cardinality (many rows match the key value) through another column. In this case, MySQL assumes that by using the key it probably will do many key lookups and that a table scan would be faster.

For small tables, a table scan often is appropriate and the performance impact is negligible. For large tables, try the following techniques to avoid having the optimizer incorrectly choose a table scan:

最新文章

  1. (转)MySQL索引原理及慢查询优化
  2. ansible 安装
  3. 用Android Studio 开发Android应用
  4. CodeForce727C. Guess the Array---交互题
  5. STM32调试大法 之 串口通讯
  6. 精通Linux的“kill”命令
  7. Wcf+EF框架搭建实例
  8. hdu 1987-How many ways(dp)
  9. win7+IE11 中开发工具报错occurredJSLugin.3005解决办法
  10. Eclipse多行同时进行编辑,可编辑或修改相同内容
  11. jsp的语法
  12. 通过Canvas及File API缩放并上传图片
  13. python day08 文件操作
  14. android PopupWindow 显示问题
  15. sql 查分数段人数
  16. python爬虫xpath的语法
  17. python安装pandas模块
  18. if语句题目练习
  19. pycharm 创建文件时,自动添加文件头注释
  20. Putty等工具中解决SSH连接超时断开的问题

热门文章

  1. Android学习笔记——log无法输出的解决方法和命令行查看log日志
  2. 小程序实现textarea随输入的文字行数变化高度自动增加
  3. 表达式树(Expression Tree)
  4. 在 ubuntu 【6.06、6.10】 上安装 oracle 10.2.0.1,并打补丁 10.2.0.5
  5. Ubuntu下制作窗口
  6. Javascript富文本编辑器
  7. weblogic创建域生产模式,输入用户名闪退
  8. Android--Led_Demo_APK控制LED灯
  9. [OSX] 在 OS X 中安装 MacPorts 指南
  10. Lua中的closure(闭合函数)