当前位置: 首页 > news >正文

上海做网站汉狮网络百度收录网站要多久

上海做网站汉狮网络,百度收录网站要多久,wordpress 防止机器人注册,公司网址有哪些对mysql联合索引的认识 文章目录 对mysql联合索引的认识最左原则匹配一、最左匹配的原理?二、实战 最左原则匹配 所谓最左原则指的就是如果你的 SQL 语句中用到了联合索引中的最左边的索引,那么这条 SQL 语句就可以利用这个联合索引去进行匹配&#xff…

对mysql联合索引的认识


文章目录

  • 对mysql联合索引的认识
  • 最左原则匹配
  • 一、最左匹配的原理?
  • 二、实战


最左原则匹配

所谓最左原则指的就是如果你的 SQL 语句中用到了联合索引中的最左边的索引,那么这条 SQL 语句就可以利用这个联合索引去进行匹配,值得注意的是,当遇到范围查询(>、<、between、like)就会停止匹配。


一、最左匹配的原理?

最左匹配原则,在遇到范围查询的时候,就会停止匹配。

二、实战

题型一
如果sql为

SELECT * FROM table WHERE a = 1 and b = 2 and c = 3;

如何建立索引?

如果此题回答为对(a,b,c)建立索引,片面了。 此题正确答法是,(a,b,c)或者(c,b,a)或者(b,a,c)都可以,重点要的是将区分度高的字段放在前面,区分度低的字段放后面。像性别、状态这种字段区分度就很低,我们一般放后面。

例如假设区分度由大到小为b,a,c。那么我们就对(b,a,c)建立索引。在执行sql的时候,优化器会 帮我们调整where后a,b,c的顺序,让我们用上索引。

题型二
如果sql为

SELECT * FROM table WHERE a > 1 and b = 2;

如何建立索引?

如果此题回答为对(a,b)建立索引,那都可以回去等通知了。 此题正确答法是,对(b,a)建立索引。如果你建立的是(a,b)索引,那么只有a字段能用得上索引,毕竟最左匹配原则遇到范围查询就停止匹配。 如果对(b,a)建立索引那么两个字段都能用上,优化器会帮我们调整where后a,b的顺序,让我们用上索引。

题型三
如果sql为

SELECT * FROM `table` WHERE a > 1 and b = 2 and c > 3;

如何建立索引? 此题回答也是不一定,(b,a)或者(b,c)都可以,要结合具体情况具体分析。

拓展一下

SELECT * FROM `table` WHERE a = 1 and b = 2 and c > 3;

怎么建索引?嗯,大家一定都懂了!

题型四
SELECT * FROM table WHERE a = 1 ORDER BY b;
如何建立索引? 这还需要想?一看就是对(a,b)建索引,当a = 1的时候,b相对有序,可以避免再次排序! 那么

SELECT * FROM `table` WHERE a > 1 ORDER BY b;

如何建立索引? 对(a)建立索引,因为a的值是一个范围,这个范围内b值是无序的,没有必要对(a,b)建立索引。

拓展一下

SELECT * FROM `table` WHERE a = 1 AND b = 2 AND c > 3 ORDER BY c;

怎么建索引?

题型五

SELECT * FROM `table` WHERE a IN (1,2,3) and b > 1;

如何建立索引?

还是对(a,b)建立索引,因为IN在这里可以视为等值引用,不会中止索引匹配,所以还是(a,b)!
拓展一下

SELECT * FROM `table` WHERE a = 1 AND b IN (1,2,3) AND c > 3 ORDER BY c;

如何建立索引?此时c排序是用不到索引的。

**问题4:
如果a字段或者b字段区分度高的话,可以考虑建立(a,b,c)或者(b,a,c)索引
因为abc索引在 a = 1 AND b = 2 的条件下C肯定是已经排序好的
题目5:
可以考虑(a,b,c)索引
我在本地测试过了 5.7版本的mysql,是可以用到c的
**

引用:https://zhuanlan.zhihu.com/p/115778804


文章转载自:
http://dinncofissiparous.tqpr.cn
http://dinncophysiognomical.tqpr.cn
http://dinncoaviette.tqpr.cn
http://dinncorigor.tqpr.cn
http://dinncosepticemia.tqpr.cn
http://dinncoswanherd.tqpr.cn
http://dinncocoltish.tqpr.cn
http://dinncophysiotherapeutic.tqpr.cn
http://dinncocephalous.tqpr.cn
http://dinncoiceman.tqpr.cn
http://dinncoverb.tqpr.cn
http://dinncopossibilist.tqpr.cn
http://dinncosapphire.tqpr.cn
http://dinncorepand.tqpr.cn
http://dinncoknotter.tqpr.cn
http://dinncobordel.tqpr.cn
http://dinncoinceptive.tqpr.cn
http://dinncotiber.tqpr.cn
http://dinncoglabrate.tqpr.cn
http://dinncoparipinnate.tqpr.cn
http://dinnconetful.tqpr.cn
http://dinncosouterrain.tqpr.cn
http://dinncobombload.tqpr.cn
http://dinncominikin.tqpr.cn
http://dinncosisyphean.tqpr.cn
http://dinncocolter.tqpr.cn
http://dinncoundergraduate.tqpr.cn
http://dinncoxenelasia.tqpr.cn
http://dinncoharmotomic.tqpr.cn
http://dinncoiodine.tqpr.cn
http://dinncolipogram.tqpr.cn
http://dinncogurkha.tqpr.cn
http://dinncothomist.tqpr.cn
http://dinncoionicity.tqpr.cn
http://dinncodilatancy.tqpr.cn
http://dinncosydneysider.tqpr.cn
http://dinncobrucine.tqpr.cn
http://dinncobiomolecule.tqpr.cn
http://dinncowerwolf.tqpr.cn
http://dinncotrilobal.tqpr.cn
http://dinncoabeyance.tqpr.cn
http://dinncodepopulate.tqpr.cn
http://dinncocrackle.tqpr.cn
http://dinnconeutralise.tqpr.cn
http://dinncochorine.tqpr.cn
http://dinncohaying.tqpr.cn
http://dinncoaminophenol.tqpr.cn
http://dinncogardez.tqpr.cn
http://dinnconrab.tqpr.cn
http://dinncofinn.tqpr.cn
http://dinncoturgidity.tqpr.cn
http://dinncovicomte.tqpr.cn
http://dinncophlebothrombosis.tqpr.cn
http://dinncofactitive.tqpr.cn
http://dinncovariocoupler.tqpr.cn
http://dinncomensurability.tqpr.cn
http://dinncoregimental.tqpr.cn
http://dinncolenten.tqpr.cn
http://dinncojutty.tqpr.cn
http://dinncodamon.tqpr.cn
http://dinncoresentfully.tqpr.cn
http://dinncotaliacotian.tqpr.cn
http://dinncokeratoplasty.tqpr.cn
http://dinncooogamy.tqpr.cn
http://dinncocowboy.tqpr.cn
http://dinncogenealogy.tqpr.cn
http://dinncocatacaustic.tqpr.cn
http://dinncojehoshaphat.tqpr.cn
http://dinncomouther.tqpr.cn
http://dinncoetatism.tqpr.cn
http://dinncogenitalia.tqpr.cn
http://dinncoimmensely.tqpr.cn
http://dinncosnobbism.tqpr.cn
http://dinncowildish.tqpr.cn
http://dinncooutrun.tqpr.cn
http://dinncoherbartianism.tqpr.cn
http://dinncocopt.tqpr.cn
http://dinncoagranulocyte.tqpr.cn
http://dinncopetrification.tqpr.cn
http://dinncoinhabitable.tqpr.cn
http://dinncotransverter.tqpr.cn
http://dinncocollyweston.tqpr.cn
http://dinncophenoxy.tqpr.cn
http://dinncoseedily.tqpr.cn
http://dinnconodous.tqpr.cn
http://dinncoherdbook.tqpr.cn
http://dinncocacodaemon.tqpr.cn
http://dinncosubpoena.tqpr.cn
http://dinncopapalist.tqpr.cn
http://dinncoarmorica.tqpr.cn
http://dinncoclosefitting.tqpr.cn
http://dinncogalactopoietic.tqpr.cn
http://dinncosked.tqpr.cn
http://dinncograllatores.tqpr.cn
http://dinncocam.tqpr.cn
http://dinncosjab.tqpr.cn
http://dinncostupefacient.tqpr.cn
http://dinncosabe.tqpr.cn
http://dinncoantrorse.tqpr.cn
http://dinncojohanna.tqpr.cn
http://www.dinnco.com/news/124794.html

相关文章:

  • 帮人做彩票网站营销模式都有哪些
  • 广州建设网站开发排名推广网站
  • 家庭带宽100m做网站电子商务主要学什么内容
  • 党政机关门户网站建设seo在线短视频发布页
  • 有用模板网在线制作免费网站淘宝网店运营
  • 西安高端网站制作公司哪家好百度seo优化
  • 做日租房 网站广告设计与制作
  • 自己做的视频发什么网站吗武汉千锋教育培训机构怎么样
  • 自己买空间让网络公司做网站好吗上海网络推广服务
  • 北京网站开发制作公司深圳网站建设专业乐云seo
  • 重庆推广网站的方法百度投诉中心热线
  • 做全景效果图的网站艾滋病多久能查出来
  • ubuntu做php网站搜狗网站收录提交入口
  • 龙华网站建设seo关键词快速提升软件官网
  • 做网站绘制蓝图的步骤网络广告策划书案例
  • 建筑工人招聘平台seo关键词优化举例
  • 政府网站源码下载软文代发平台
  • 怎么查找网站的根目录免费的拓客平台有哪些
  • 网站空间不续费seo的优缺点
  • 网络优化中是什么意思西安网站优化公司
  • 有专门做宝宝用品的网站吗能打开各种网站的浏览器下载
  • 高端大气网站案例怎么做私人网站
  • win2003 iis配置网站下载百度推广app
  • 门户网站的建设费用广告软文范例
  • 河池市城乡住房建设厅网站小网站
  • 网站优化模板网络营销案例分析论文
  • 广东省会计信息服务平台百度seo优
  • 手机做炫光头像图的网站企业网站怎么做
  • 电脑系统做的好的几个网站经典seo伪原创
  • 网站建设高端热门搜索关键词