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

如何做推广麦当劳的网站wordpress ssl部署

如何做推广麦当劳的网站,wordpress ssl部署,dedecms搭建网站,医院网站html模板提示#xff1a;mysql索引最左前缀使用的规则#xff0c;以及索引失效和部分字段索引失效 文章目录 索引使用法则最左前缀法则 索引执行explain分析遵守联合索引最左前缀法则#xff08;索引有效#xff09;未遵守联合索引最左前缀法则#xff08;索引失效或部分索引失效mysql索引最左前缀使用的规则以及索引失效和部分字段索引失效 文章目录 索引使用法则最左前缀法则 索引执行explain分析遵守联合索引最左前缀法则索引有效未遵守联合索引最左前缀法则索引失效或部分索引失效 思考 索引使用法则 最左前缀法则 联合索引多列索引要遵守最左前缀法则(最左边的字段必须存在,跳过某一字段后面字段索引失效)造成索引失效或者部分索引失效 1、创建表 city | CREATE TABLE city (ID int NOT NULL AUTO_INCREMENT,Name char(35) NOT NULL DEFAULT ,CountryCode char(3) NOT NULL DEFAULT ,District char(20) NOT NULL DEFAULT ,Info json DEFAULT NULL,PRIMARY KEY (ID) ) ENGINEInnoDB AUTO_INCREMENT4080 DEFAULT CHARSETutf8mb4 COLLATEutf8mb4_0900_ai_ci 2、创建联合索引多列索引 mysql create index idx_Name_CountryCode_District on city (Name,CountryCode,District);Query OK, 0 rows affected (0.16 sec) Records: 0 Duplicates: 0 Warnings: 0 create index idx_字段1_字段2......字段n 3、查看索引 show index city; | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | city | 0 | PRIMARY | 1 | ID | A | 4079 | NULL | NULL | | BTREE | | | YES | NULL | | city | 1 | idx_Name_CountryCode_District | 1 | Name | A | 3998 | NULL | NULL | | BTREE | | | YES | NULL | | city | 1 | idx_Name_CountryCode_District | 2 | CountryCode | A | 4056 | NULL | NULL | | BTREE | | | YES | NULL | | city | 1 | idx_Name_CountryCode_District | 3 | District | A | 4078 | NULL | NULL | | BTREE | | | YES | NULL | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- NameCountryCodeDistrict三个字段创建的联合索引正常显示 上述步骤创建联合索引以及查看联合索引等工作完成 索引执行explain分析 遵守联合索引最左前缀法则索引有效 1、全表执行计划查询 mysql explain select * from city; ----------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ----------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ALL | NULL | NULL | NULL | NULL | 4079 | 100.00 | NULL | ----------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec) type:全表扫描 key未使用到索引 2、第一个索引字段Name执行查询 mysql explain select * from city where NameJabaliya- ; --------------------------------------------------------------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ref | idx_Name_CountryCode_District | idx_Name_CountryCode_District | 140 | const | 1 | 100.00 | Using index condition | --------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec) key使用的所以有Name_CountryCode_District key_len;索引长度140也是Name索引长度140 3、前两个字段Name、CountryCode索引查询执行 mysql explain select * from city where NameJabaliyaand CountryCodeVIR; --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ref | idx_Name_CountryCode_District | idx_Name_CountryCode_District | 152 | const,const | 1 | 100.00 | Using index condition | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- key_len152上述Name索引字段为140CountryCode字段索引长度等于152-14012 4、三个字段Name、CountryCode、District索引查询执行 mysql explain select * from city where NameJabaliyaand CountryCodeVIR and DistrictManicaland; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ref | idx_Name_CountryCode_District | idx_Name_CountryCode_District | 232 | const,const,const | 1 | 100.00 | Using index condition | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec) key_len:District索引长度等于232-152 上述三种索引查询情况下索引都正常履行了自身的职责遵守了联合索引多列索引的最做前缀法则所有索引都正常未造成索引失效 未遵守联合索引最左前缀法则索引失效或部分索引失效 1.第一个索引字段、第三个索引字段联合查询执行 mysql explain select * from city where NameJabaliyaand DistrictManicaland; --------------------------------------------------------------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ref | idx_Name_CountryCode_District | idx_Name_CountryCode_District | 140 | const | 1 | 10.00 | Using index condition | --------------------------------------------------------------------------------------------------------------------------------------------------------------- 当执行第一个字段索引和第三个字段索引时跳过第二个字段索引进行查询的时key_len显示为140和使用explain select * from city where NameJabaliya’查询的索引长度一样name的索引字段等于140而District索引长度未0表示District字段索引失效了当联合索引跳过中间索引时会造成部分索引失效 2、第二个索引字段和第三个索引字段查询执行 mysql explain select * from city where CountryCodeVIR and DistrictManicaland; ----------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ----------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ALL | NULL | NULL | NULL | NULL | 4079 | 1.00 | Using where | ----------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec) keynull 未使用到索引 key_lennull 跳过第一个字段索引未遵守联合索引最左前缀法则造成CountryCode、District索引已失效 思考 explain select * from city where DistrictManicaland and NameNablus and CountryCodePSE; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | city | NULL | ref | idx_Name_CountryCode_District | idx_Name_CountryCode_District | 232 | const,const,const | 1 | 100.00 | Using index condition | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec)总结执行查询时只要遵守联合索引最左前缀法则和索引查询时的前后位置无任何关系联合索引遵守idx_Name_CountryCode_District顺序和 explain select * from city where District‘Manicaland’ and Name‘Nablus’ and CountryCode‘PSE’;无关系只要查询中遵守最左前缀法则即可
http://www.hkea.cn/news/14305835/

相关文章:

  • 电梯网站建设app开发公司选择指南及误区
  • 做网站需要花多少钱wordpress宠物主题
  • 找方案的网站网站设计合同模板
  • 一些js特效的网站推荐wordpress 忘记管理员
  • 1个人做几个网站的负责人表白网页制作免费网站
  • 服装网站 欣赏装企erp管理系统
  • 品质商城网站建设三亚婚纱摄影 织梦网站源码
  • 织梦网站去除技术支持东莞定制建站网站推广公司
  • 给公司做网站软件商丘seo教程
  • wordpress仿站header专门做团购的网站
  • 临沂网站开发技术员广州设计公司前十名
  • 自己做的网站实现扫码跳转福州企业网站建站模板
  • 站长工具下载app网站前面的小图标怎么做
  • 视频网站怎么做可以播放电视剧表格上传网站
  • 深圳鸿运通网站建设大型网站如何开发
  • 做网站有自己的服务器吗网络推广营销课程
  • 百度流量推广项目系统优化软件有哪些
  • 设计旅游网站的主色调wordpress 重复文章
  • 响应式网站建设多少钱金华外贸网站建设
  • 两学一做教育考试网站免费网页设计作品
  • 常州网站推西安市城乡建设档案馆网站
  • 海南省建设考试网站公司介绍模板图片
  • wordpress仿站标签宁波北京网站建设
  • 网站引导页怎么做边个网站可以接模具做
  • 用什么网站做浏览器主页怎样快速建设网站模板
  • 北京市住房建设投资中心网站网站浏览图片怎么做
  • 开网站空间流量怎么选择wordpress 输入框
  • 六安网站自然排名优化价格做淘宝有哪些货源网站
  • 网站在阿里云备案流程推荐10网站
  • 怎么做网站推广林芝地区工作室logo设计