SQL> set linesize 200
SQL> set pagesize 200
SQL> set autot trace
SQL> select distinct department_name
from hr.departments dept, hr.employees emp
where dept.department_id = emp.department_id; 2 3 11 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 93782236 -----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 27 | 513 | 4 (25)| 00:00:01 |
| 1 | HASH UNIQUE | | 27 | 513 | 4 (25)| 00:00:01 |
| 2 | NESTED LOOPS | | 106 | 2014 | 3 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| DEPARTMENTS | 27 | 432 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | EMP_DEPARTMENT_IX | 4 | 12 | 0 (0)| 00:00:01 |
----------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 4 - access("DEPT"."DEPARTMENT_ID"="EMP"."DEPARTMENT_ID") Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
10 consistent gets
0 physical reads
0 redo size
622 bytes sent via SQL*Net to client
419 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
11 rows processed 走的是hash unique:
Oracle10g在distinct操作时作了算法改进,使用Hash Unique 代理了以前的Sort Unique.该行为由隐藏参数” _gby_hash_aggregation_enabled”决定,optimizer_features_enable设置为10.2.0.1时默认为TRUE. SQL> set linesize 200
SQL> set pagesize 200
SQL> ALTER SESSION SET "_gby_hash_aggregation_enabled" = FALSE; Session altered. SQL> set autot trace
SQL> select distinct department_name
from hr.departments dept, hr.employees emp
where dept.department_id = emp.department_id; 2 3 11 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 1155849093 -----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 27 | 513 | 4 (25)| 00:00:01 |
| 1 | SORT UNIQUE | | 27 | 513 | 4 (25)| 00:00:01 |
| 2 | NESTED LOOPS | | 106 | 2014 | 3 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| DEPARTMENTS | 27 | 432 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | EMP_DEPARTMENT_IX | 4 | 12 | 0 (0)| 00:00:01 |
----------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 4 - access("DEPT"."DEPARTMENT_ID"="EMP"."DEPARTMENT_ID") Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
10 consistent gets
0 physical reads
0 redo size
622 bytes sent via SQL*Net to client
419 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
11 rows processed

Hash unique和Sort unique的更多相关文章

  1. SORT UNIQUE|AGGREGATE|GROUP BY|ORDER BY|JOIN

    相信做oracle开发和管理的朋友对sort肯定不会陌生,大家通常都遇到这样那样的排序性能问题,所以我写这一系列关于sort的文章告诉大家在oracle里面sort是怎么一回事以及如果调整sort获得 ...

  2. 去重函数unique,sort,erase的应用

    std::unique 一.总述 unique函数属于STL中比较常用函数,它的功能是元素去重.即"删除"序列中所有相邻的重复元素(只保留一个).此处的删除,并不 是真的删除,而是 ...

  3. Nested Loops,Hash Join 和 Sort Merge Join. 三种不同连接的不同:

    原文:https://blog.csdn.net/tianlesoftware/article/details/5826546 Nested Loops,Hash Join 和 Sort Merge ...

  4. vector 去除重复元素(sort + unique)

    struct SIndexData { string sCode; int iDate; int iTime; double f1; SIndexData(): iDate(0), iTime(0) ...

  5. PAT L2-021. 点赞狂魔 /// sort+unique去重

    https://www.patest.cn/contests/gplt/L2-021 题目大意: 微博上有个“点赞”功能,你可以为你喜欢的博文点个赞表示支持.每篇博文都有一些刻画其特性的标签,而你点赞 ...

  6. 62. Unique Paths && 63 Unique Paths II

    https://leetcode.com/problems/unique-paths/ 这道题,不利用动态规划基本上规模变大会运行超时,下面自己写得这段代码,直接暴力破解,只能应付小规模的情形,当23 ...

  7. php Redis函数使用总结(string,hash,list, set , sort set )

    对于:string, set , sort set , hash 的增,改操作,是同一个命令,但是把它当改操作时,及时成功返回值依旧为0 对于:list结构来说,增删改查自有一套方法.   <? ...

  8. Nested loops、Hash join、Sort merge join(三种连接类型原理、使用要点)

    nested loop 嵌套循环(原理):oracle从较小结果集(驱动表.也可以被称为outer)中读取一行,然后和较大结果集(被侦查表,也可以叫做inner)中的所有数据逐条进行比较(也是等值连接 ...

  9. Differences between INDEX, PRIMARY, UNIQUE, FULLTEXT in MySQL?

    487down vote Differences KEY or INDEX refers to a normal non-unique index.  Non-distinct values for ...

随机推荐

  1. MD5加密 Java源代码

    package lwp; /** * * @author 梁WP */ public class MD5_Encoding { // RFC1321中定义的标准4*4矩阵的常量定义. static f ...

  2. 各大浏览器CSS Hack收集

    各大浏览器CSS Hack收集  >>>>>>>>>>>>>>>>>>>>> ...

  3. a标签的背景图在ie8下显示问题

    今天遇到个小问题,纠结了很久,分享下 a标签添加背景图,需要给a添加display:block样式 但是在ie8下还是不能显示背景图,开始以为是由于a标签为空造成的,试了下添加内容也没用,后来注意到一 ...

  4. linux的grep命令

    参考文档如下: linux grep命令 grep abb15455baeb4b23ab47540272ec47eb epps-sas.log | grep operateSettleBill exp ...

  5. apache commons io包基本功能

    1. http://jackyrong.iteye.com/blog/2153812 2. http://www.javacodegeeks.com/2014/10/apache-commons-io ...

  6. 用Ueditor存入数据库带HTML标签的文本,从数据库取出来后,anjular用ng-bind-html处理带HTML标签的文本

    ng.module('index-filters', []) .filter('trustHtml', function ($sce) { return function (input) { retu ...

  7. java开发规范总结_命名规范

    规范需要平时编码过程中注意,是一个慢慢养成的好习惯 1.文件 1.属性文件后缀为properties,并且符合java中i18n的规范:   2.对于各产品模块自己的配置文件必须放置在自己模块的con ...

  8. 平衡搜索树(一) AVL树

    AVL树 AVL树又称为高度平衡的二叉搜索树,是1962年有俄罗斯的数学家G.M.Adel'son-Vel'skii和E.M.Landis提出来的.它能保持二叉树的高度 平衡,尽量降低二叉树的高度,减 ...

  9. vs 2013 编译zlib

    zlib下载地址: http://pan.baidu.com/s/1pJqTcoV \zlib-1.2.8\contrib\vstudio\vc10\zlibvc.sln 打开这个文件, 根据提示, ...

  10. 如何使一个input文本框随其中内容而变化长度。

    第一:<input type="text" onkeydown="this.onkeyup();" onkeyup="this.size=(th ...