group by 替代distinct
SQL> select distinct employee_id,first_name from test1; 107 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 255531131 ------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6647K| 158M| | 67481 (1)| 00:13:30 |
| 1 | HASH UNIQUE | | 6647K| 158M| 229M| 67481 (1)| 00:13:30 |
| 2 | TABLE ACCESS FULL| TEST1 | 6647K| 158M| | 19570 (1)| 00:03:55 |
------------------------------------------------------------------------------------ Note
-----
- dynamic sampling used for this statement (level=2) Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
142133 consistent gets
71297 physical reads
0 redo size
2749 bytes sent via SQL*Net to client
496 bytes received via SQL*Net from client
9 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
107 rows processed SQL> select employee_id,first_name from test1 group by employee_id,first_name; 107 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 1431305903 ----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6647K| 158M| 19781 (2)| 00:03:58 |
| 1 | HASH GROUP BY | | 6647K| 158M| 19781 (2)| 00:03:58 |
| 2 | TABLE ACCESS FULL| TEST1 | 6647K| 158M| 19570 (1)| 00:03:55 |
---------------------------------------------------------------------------- Note
-----
- dynamic sampling used for this statement (level=2) Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
142133 consistent gets
71297 physical reads
0 redo size
2749 bytes sent via SQL*Net to client
496 bytes received via SQL*Net from client
9 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
107 rows processed
group by 替代distinct的更多相关文章
- 什么办法可以替代distinct
今天在论坛上看到一个面试题,是说有什么办法可以替代distinct,得到同样的结果.答案都被大家说的差不多了,发现挺有意思的,就记录一下: SQL> select num from t1; ...
- group by和distinct语句的执行顺序
同一条语句之中,如果同时有group by和distinct语句,是先group by后distinct,还是先distinct后group by呢? 先说结论:先group by后distinct. ...
- MYSQL 行转列 以及基本的聚合函数count,与group by 以及distinct组合使用
在统计查询中,经常会用到count函数,这里是基础的 MYSQL 行转列 以及基本的聚合函数count,与group by 以及distinct组合使用 -- 创建表 CREATE TABLE `tb ...
- HIVE点滴:group by和distinct语句的执行顺序
同一条语句之中,如果同时有group by和distinct语句,是先group by后distinct,还是先distinct后group by呢? 先说结论:先group by后distinct. ...
- hive里的group by和distinct
hive里的group by和distinct 前言 今天才明确知道group by实际上还是有去重读作用的,其实细想一下,按照xx分类,肯定相同的就算是一类了,也就相当于去重来,详细的看一下. gr ...
- sql左外连接、右外连接、group by、distinct(区别)、intersect(交叉)、通配符、having
连接条件可在FROM或WHERE子句中指定,建议在FROM子句中指定连接条件.WHERE和HAVING子句也可以包含搜索条件,以进一步筛选连接条件所选的行. 连接可分为以下几类 ...
- MySQL中Group By,distinct使用注意事项
mysql> select * from test; +----+-------+------+-------+ | id | name | age | class | +----+------ ...
- 标量子查询优化(用group by 代替distinct)
标量子查询优化 当使用另外一个SELECT 语句来产生结果中的一列的值的时候,这个查询必须只能返回一行一列的值.这种类型的子查询被称为标量子查询 在某些情况下可以进行优化以减少标量子查询的重复执行,但 ...
- group by 和 distinct 的区别
SELECT fs.card_id, fs. NAME, fs.email, fs.phone_num, fs.weixin_num, fs.permission, fs.open_id FROM f ...
随机推荐
- eclipse中svn插件的安装
Svn(Subversion)是近年来崛起的版本管理工具,在当前的开源项目里(J2EE),几乎95%以上的项目都用到了SVN.Subversion项目的初衷是为了替换当年开源社区最为流行的版本控制软件 ...
- radio的change事件
radio的change事件 <scripttype="text/javascript"> $(document).ready(function(){ $(" ...
- android下4G上网卡
架构: APP Call Trachker/SMS Dispatch/Service Tracker/Data Tracker ------------------------------------ ...
- 删除mysql重复记录的办法
网上有很多的办法,但是大多数都是通过临时表的办法,其实你是可以用一句简单的sql就可以做到: alter ignore table SOMETABLE add primary key(fields n ...
- dedeCMS修改文章更新发布时间问题
今天在dedeCMS系统中,修改或文章时发现,只要提交以后,文章发布时间便是当前时间.但有时候修改文章以后并不想把文章发布时间也更新成修改时间.我希望的是,修改文章不对时间做更改保持文章原有发布时间, ...
- JavaScript+DOM编程艺术【读书笔记】
第四章笔记: 如何让一个a标签不跳转: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www. ...
- (ASP页面查询等待提示效果)GridViewなどで検索中に「処理中メッセージ」を表示する方法(※他の長い時間処理も参照できる)
原博客 http://ino1970.blog119.fc2.com/blog-entry-163.html GridViewなどで検索中に「処理中メッセージ」を表示する方法 「GridViewなどで ...
- .NET(C#):获取进程的CPU使用状况
第一个是通过手动的方法来计算CPU使用比例:CPU使用比例 = 在间隔时间内进程的CPU使用时间 除以 计算机逻辑CPU数量. 使用Process类的UserProcessorTime和Privile ...
- 使用正则表达式统计vs项目代码总行数[转]
怎么统计VS2008中工程的总共代码行数?怎么统计VS2008中工程的总共代码行数?在一个大工程中有很多的源文件和头文件,我如何快速统计总行数? ------解决方案----------------- ...
- CocoaPods详解之----进阶篇
作者:wangzz原文地址:http://blog.csdn.net/wzzvictory/article/details/19178709转载请注明出处如果觉得文章对你有所帮助,请通过留言或关注微信 ...