MySql 优化

To make a slow SELECT ... WHERE
query faster, the first thing to check is whether you can add an index. Set up indexes on columns used in the WHERE
clause, to speed up evaluation, filtering, and the final retrieval of results. To avoid wasted disk space, construct a small set of indexes that speed up many related queries used in your application.

优化select .. where 的查询语句 ,第一步应该检查是否添加了索引。在 where 从句的列中添加索引可以令求值,过滤,和对最终结果的检索加速。为了避免磁盘的浪费,构造一小个索引的集合 可以使你应用中相关查询加速。

  • 最左最左匹配
    If the table has a multiple-column index, any leftmost prefix of the index can be used by the optimizer to look up rows. For example, if you have a three-column index on(col1, col2, col3), you have indexed search capabilities on(col1),(col1, col2), and(col1, col2, col3). For more information, see Section 9.3.5, “Multiple-Column Indexes”.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 系统层面(基本不用动,看了下,买的云服务器基本都已经优化过了) 内核相关参数(/etc/sysctl.conf) ...
    神奇大叶子阅读 6,164评论 0 4
  • 我发现一个问题,每周我都会把命题拖到最后才来写,导致每次写命题都心力憔悴苦不堪言要死不活…这周我想了很久都不知道要...
    飒然的秋阅读 3,301评论 6 1
  • 庄子和鲲身边,分别出现了两个人。 站在庄子身边那个人一身灰衣,手里握着一卷书卷,看上去书生气极其浓厚。站在鲲旁边的...
    老愤青阅读 2,929评论 0 1
  • 11.07 嘟嘟103.104期(历史没有真相,只残存一个道理) 古时候这些例子,凿壁借光、囊萤夜读,基本不可能是...
    活雷疯阅读 1,768评论 0 1
  • J失恋了,又在谈婚论嫁的时候失恋了。 去年这个时候,我在学校复习该死的国考,J打电话说,你知道吗?我一宿一宿的哭,...
    给我一个橘子阅读 3,297评论 2 3