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

长春火车站是哪个站网站建设费用明细表

长春火车站是哪个站,网站建设费用明细表,做网站阳泉,做机械设备的做哪个网站推广较好在MySQL中,即使表中没有数据,查询优化器也会考虑使用索引来执行查询。但在某些情况下,查询优化器可能会选择不使用索引,这通常是基于成本效益分析的结果。 表中没有任何数据时,无论是否使用索引,查询结果都…

在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 id=1;
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+--------------------------------+
| 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 id=1;
+----+-------------+-------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
| 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 b=1;
+----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+--------------------------+
| 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 b=1;
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
| 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 b=1 and c=1;
> explain select * from t1 where c=1;
> 
> explain select * from t2 where b=1 and c=1;
> explain select * from t2 where c=1;
http://www.zhongyajixie.com/news/55818.html

相关文章:

  • 做网站用的到minitab么廊坊百度快照优化排名
  • 网络营销的网站定位关键词分析工具网站
  • 网站建设服务平台网页软文素材网站
  • 南川网站制作女生seo专员很难吗为什么
  • 济南企业网站建设关键词智能优化排名
  • 东莞网站制作 东莞企业网站制作外包网站有哪些
  • 哪些网站做的比较炫seo的概念是什么
  • 如何做游戏网站公司seo是什么职位
  • h5 网站建设成都关键词优化报价
  • 网站建设的技术亮点开鲁视频
  • 哪个网站可以做空比特币重大军事新闻
  • 宣城市网站建设手机百度网盘下载慢怎么解决
  • 怎么用PS做网站横幅快速提高排名
  • 网站的上一页怎么做的百度推广方式
  • b2c购物网站建设方案百度竞价推广教程
  • 南京网站建设百度浏览器网址
  • 免费注册建网站新余seo
  • 百姓网全国免费发布信息湖北百度seo
  • 如何做企业网站20条优化措施
  • 收费小说网站怎么做国家提供的免费网课平台
  • 工业设计研究生院校排名无锡网站优化公司
  • 网站改版建设主要seo站内优化教程
  • 在线爱情动做网站北京seo公司wyhseo
  • 移动端网站开发公司网络营销推广经验总结
  • 开发公司安全工作总结汇报google seo是什么啊
  • java 自动登录网站东莞网站建设市场
  • 南通网站建设案例百度app客服人工在线咨询
  • 征纳互动平台重庆百度推广关键词优化
  • 网站招聘方案怎么做百度关键词检测工具
  • 网站建设帝国优化设计电子版在哪找