博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mysql 和Oracle rows 区别
阅读量:4603 次
发布时间:2019-06-09

本文共 3674 字,大约阅读时间需要 12 分钟。

mysql>  explain select t1.* from t2 ,t1 where t2.id=t1.id and t2.id<3;\+----+-------------+-------+------+---------------+------+---------+------+--------+----------------------------------------------------+| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows   | Extra                                              |+----+-------------+-------+------+---------------+------+---------+------+--------+----------------------------------------------------+|  1 | SIMPLE      | t2    | ALL  | NULL          | NULL | NULL    | NULL |    134 | Using where                                        ||  1 | SIMPLE      | t1    | ALL  | NULL          | NULL | NULL    | NULL | 392625 | Using where; Using join buffer (Block Nested Loop) |+----+-------------+-------+------+---------------+------+---------+------+--------+----------------------------------------------------+2 rows in set (0.00 sec)mysql> select count(*) from t2;+----------+| count(*) |+----------+|      134 |+----------+1 row in set (0.00 sec)mysql> select count(*) from t2 where id<3;+----------+| count(*) |+----------+|      128 |+----------+1 row in set (0.00 sec)驱动表 一般返回较少的记录:mysql> explain select t1.* from (select * from t2 where id<3) t2 ,t1 where t2.id=t1.id;+----+-------------+------------+------+---------------+-------------+---------+--------------+--------+-------------+| id | select_type | table      | type | possible_keys | key         | key_len | ref          | rows   | Extra       |+----+-------------+------------+------+---------------+-------------+---------+--------------+--------+-------------+|  1 | PRIMARY     | t1         | ALL  | NULL          | NULL        | NULL    | NULL         | 392625 | Using where ||  1 | PRIMARY     | 
| ref |
|
| 5 | DEVOPS.t1.id | 10 | NULL || 2 | DERIVED | t2 | ALL | NULL | NULL | NULL | NULL | 134 | Using where |+----+-------------+------------+------+---------------+-------------+---------+--------------+--------+-------------+3 rows in set (0.00 sec)是预估的需要扫描的行数不是返回的行数这就是两者的区别Oracle 是预估返回的行数MySQL 是预估扫描的行数,显示需要扫描的行数mysql> analyze table t2;+-----------+---------+----------+----------+| Table | Op | Msg_type | Msg_text |+-----------+---------+----------+----------+| DEVOPS.t2 | analyze | status | OK |+-----------+---------+----------+----------+1 row in set (0.17 sec)mysql> explain select t1.* from t2 ,t1 where t2.id=t1.id and t2.id=3;+----+-------------+-------+------+---------------+------+---------+------+--------+----------------------------------------------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------+------+---------------+------+---------+------+--------+----------------------------------------------------+| 1 | SIMPLE | t2 | ALL | NULL | NULL | NULL | NULL | 16192 | Using where || 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 392625 | Using where; Using join buffer (Block Nested Loop) |+----+-------------+-------+------+---------------+------+---------+------+--------+----------------------------------------------------+2 rows in set (0.00 sec)mysql> select count(*) from t2;+----------+| count(*) |+----------+| 16390 |+----------+1 row in set (0.01 sec)mysql> select count(*) from t2 where id=3;+----------+| count(*) |+----------+| 6 |+----------+1 row in set (0.01 sec)

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6199894.html

你可能感兴趣的文章
JavaScript面试题
查看>>
[转帖]架构师眼中的高并发架构
查看>>
ios的一些开源资源
查看>>
HTTP 错误 500.21 - Internal Server Error 解决方案
查看>>
Bucks sign Sanders to $44 million extension
查看>>
【PHP】Windows下配置用mail()发送邮件
查看>>
Nhibernate和EF的区别
查看>>
基于java spring框架开发部标1078视频监控平台精华文章索引
查看>>
人类简史
查看>>
java 设计模式学习
查看>>
【Python使用】使用pip安装卸载Python包(含离线安装Python包)未完成???
查看>>
一语道破项目管理知识体系五大过程组
查看>>
C# 备份、还原、拷贝远程文件夹
查看>>
在windows环境下运行compass文件出现的错误提示解决方案
查看>>
CSS常用样式--font
查看>>
【英语天天读】Choose companion
查看>>
恩如氏--蜗牛精华补水蚕丝面膜
查看>>
大工具-收藏
查看>>
codevs3027 线段覆盖 2
查看>>
markdown
查看>>