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

无棣县建设局网站网站站点建立

无棣县建设局网站,网站站点建立,公司内部网站,济宁人才网招聘信息网在MySQL中#xff0c;即使表中没有数据#xff0c;查询优化器也会考虑使用索引来执行查询。但在某些情况下#xff0c;查询优化器可能会选择不使用索引#xff0c;这通常是基于成本效益分析的结果。 表中没有任何数据时#xff0c;无论是否使用索引#xff0c;查询结果都…在MySQL中即使表中没有数据查询优化器也会考虑使用索引来执行查询。但在某些情况下查询优化器可能会选择不使用索引这通常是基于成本效益分析的结果。 表中没有任何数据时无论是否使用索引查询结果都是一样的。但直接扫描表全表扫描可能比使用索引更快因为即使是空表访问索引也需要一定的开销但并不会带来性能提升。 create table test(id int primary key, name varchar(10)); Query OK, 0 rows affected (0.10 sec)mysql explain select * from test where id1; ------------------------------------------------------------------------------------------------------------------------------ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ------------------------------------------------------------------------------------------------------------------------------ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | no matching row in const table | ------------------------------------------------------------------------------------------------------------------------------ 1 row in set, 1 warning (0.00 sec)mysql insert into test value(1, a); Query OK, 1 row affected (0.01 sec)mysql explain select * from test where id1; ---------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ---------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | test | NULL | const | PRIMARY | PRIMARY | 4 | const | 1 | 100.00 | NULL | ---------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec)使用如下SQL语句建表并使用b列作为条件查询。按照索引最左匹配原则此时应该无法使用索引。但如果表中只包含主键列和索引列此时查询优化器还是会使用索引。示例如下 CREATE TABLE t1 (id int NOT NULL,a int DEFAULT NULL,b int DEFAULT NULL,c int DEFAULT NULL,PRIMARY KEY (id),KEY inx_abc (a,b,c) );CREATE TABLE t2 (id int NOT NULL,a int DEFAULT NULL,b int DEFAULT NULL,c int DEFAULT NULL,d int DEFAULT NULL,PRIMARY KEY (id),KEY inx_abc (a,b,c) );# 插入两条数据 insert into t1 value(1, 1, 1, 1); insert into t2 value(1, 1, 1, 1, 1); explain select * from t1 where b1; ---------------------------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ---------------------------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | t1 | NULL | index | inx_abc | inx_abc | 15 | NULL | 1 | 100.00 | Using where; Using index | ---------------------------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec) explain select * from t2 where b1; ----------------------------------------------------------------------------------------------------------- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | ----------------------------------------------------------------------------------------------------------- | 1 | SIMPLE | t2 | NULL | ALL | NULL | NULL | NULL | NULL | 1 | 100.00 | Using where | ----------------------------------------------------------------------------------------------------------- 1 row in set, 1 warning (0.00 sec)同理以下SQL也有类似现象 explain select * from t1 where b1 and c1;explain select * from t1 where c1;explain select * from t2 where b1 and c1;explain select * from t2 where c1;
http://www.dnsts.com.cn/news/207716.html

相关文章:

  • 局域网手机网站建设北京建设教育协会官方网站
  • php做网站首页的代码键词优化排名
  • 美食地图网站开发百度验证网站的好处
  • 门户网站建设 总结赞助网站怎么做
  • wordpress编辑模板标题深圳seo优化推广公司
  • 垂直门户网站wordpress二手车模板
  • 湘潭交通网站怎么做简易手机网站
  • wordpress全站音乐wordpress小工具自定义
  • 能利用双股铜芯电话线做网站吗网站不兼容ie6
  • 南宁网站建设方案报价装修设计师在哪里找
  • 河北外贸网站建设深圳做网站排名哪家好
  • 网站流量统计怎么做的wordpress 微信主体
  • 北京市优化网站建设网站后期人员薪酬
  • 大师摄影作品网站做网站软件的
  • 百度上做网站重庆比较好的广告公司
  • 网站登录密码忘记怎么办吉林seo技术交流
  • 作品展示html5网站模板南昌做网站公司
  • 软文写作案例付费做网站关键词优化是怎么做的呀
  • 中天建设集团有限公司总网站大连做网站电话
  • 如何在百度上做网站推广开发游戏用什么编程软件
  • 合肥电信网站备案滴滴一年亏损109亿
  • 怎样做网站管理国外 外贸 网站 源码
  • 大型网站 php网站备案流程及步骤
  • 在线画画网站笔记本网站开发背景
  • 九江集团网站建设公司营销型企业网站案例
  • 什么是网站开发框架北京南站附近景点
  • 网站psd模版在网站做登记表备案 如果修改
  • 企业做网站怎么做个人crm
  • 网站的规划和建设方案站长素材音效下载
  • 糯米团网站怎么做wordpress美容主题