[20171211]HASH GROUP BY ?354?.txt

简介: [20171211]HASH GROUP BY not used when using more that 354 aggregate functions.txt --//http://msutic.

[20171211]HASH GROUP BY not used when using more that 354 aggregate functions.txt

--//http://msutic.blogspot.com/2017/11/hash-group-by-not-used-when-using-more.html
--//当查询354 unique aggregate functions which is using HASH GROUP BY.重复测试看看.

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

set head off
spool /tmp/354.txt
select  ',sum('|| rownum || ') k'||rownum from dual connect by level<=354;
spool off

--//以/tmp/354.txt为蓝本,修改如下sql语句:

$ head /tmp/354.txt
SELECT * FROM (SELECT LEVEL ID FROM DUAL CONNECT BY LEVEL < 1000) a,
(  SELECT
123 ID
,sum(1) k1
,sum(2) k2
,sum(3) k3
,sum(4) k4
,sum(5) k5
,sum(6) k6
,sum(7) k7

$ tail /tmp/354.txt
,sum(348) k348
,sum(349) k349
,sum(350) k350
,sum(351) k351
,sum(352) k352
,sum(353) k353
,sum(354) k354
  FROM DUAL
           GROUP BY 123) b
    WHERE     a.ID = b.ID(+);

SCOTT@book> @ /tmp/354.txt
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  0aumtwvs2ssk9, child number 0
-------------------------------------
SELECT * FROM (SELECT LEVEL ID FROM DUAL CONNECT BY LEVEL < 1000) a,  (
SELECT 123 ID ,sum(1) k1 ,sum(2) k2 ,sum(3) k3 ,sum(4) k4 ,sum(5) k5
,sum(6) k6 ,sum(7) k7 ,sum(8) k8 ,sum(9) k9 ,sum(10) k10 ,sum(11) k11
,sum(12) k12 ,sum(13) k13 ,sum(14) k14 ,sum(15) k15 ,sum(16) k16
,sum(17) k17 ,sum(18) k18 ,sum(19) k19 ,sum(20) k20 ,sum(21) k21
,sum(22) k22 ,sum(23) k23 ,sum(24) k24 ,sum(25) k25 ,sum(26) k26
,sum(27) k27 ,sum(28) k28 ,sum(29) k29 ,sum(30) k30 ,sum(31) k31
,sum(32) k32 ,sum(33) k33 ,sum(34) k34 ,sum(35) k35 ,sum(36) k36
,sum(37) k37 ,sum(38) k38 ,sum(39) k39 ,sum(40) k40 ,sum(41) k41
,sum(42) k42 ,sum(43) k43 ,sum(44) k44 ,sum(45) k45 ,sum(46) k46
,sum(47) k47 ,sum(48) k48 ,sum(49) k49 ,sum(50) k50 ,sum(51) k51
,sum(52) k52 ,sum(53) k53 ,sum(54) k54 ,sum(55) k55 ,sum(56) k56
,sum(57) k57 ,sum(58) k58 ,sum(59) k59 ,sum(60) k60 ,sum(61) k61
,sum(62) k62 ,sum(63) k63 ,sum(64) k64 ,sum(65) k65 ,sum(66) k66
,sum(67) k67 ,sum(68) k68 ,sum(69) k69 ,sum(70) k70 ,sum(71) k71
,sum(72)

Plan hash value: 2053589652

-------------------------------------------------------------------------------------------------------------------
| Id  | Operation                      | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time   |  OMem |  1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |      |        |       |     4 (100)|          |       |       |          |
|*  1 |  HASH JOIN OUTER               |      |      1 |  4618 |     4   (0)| 00:00:01 |  2293K|  2293K| 1659K (0)|
|   2 |   VIEW                         |      |      1 |    13 |     2   (0)| 00:00:01 |       |       |          |
|   3 |    CONNECT BY WITHOUT FILTERING|      |        |       |            |          |       |       |          |
|   4 |     FAST DUAL                  |      |      1 |       |     2   (0)| 00:00:01 |       |       |          |
|   5 |   VIEW                         |      |      1 |  4605 |     2   (0)| 00:00:01 |       |       |          |
|   6 |    HASH GROUP BY               |      |      1 |       |     2   (0)| 00:00:01 |   677K|   677K|  710K (0)|
|   7 |     FAST DUAL                  |      |      1 |       |     2   (0)| 00:00:01 |       |       |          |
-------------------------------------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$2 / A@SEL$1
   3 - SEL$2
   4 - SEL$2 / DUAL@SEL$2
   5 - SEL$3 / B@SEL$1
   6 - SEL$3
   7 - SEL$3 / DUAL@SEL$3

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("A"."ID"="B"."ID")


--//如果增加1行.注意下划线内容:
$ tail /tmp/354.txt
,sum(349) k349
,sum(350) k350
,sum(351) k351
,sum(352) k352
,sum(353) k353
,sum(354) k354
,sum(355) k355
~~~~~~~~~~~~~~~ 
  FROM DUAL
           GROUP BY 123) b
    WHERE     a.ID = b.ID(+);

SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  6j1yhy3nu7wzj, child number 0
-------------------------------------
SELECT * FROM (SELECT LEVEL ID FROM DUAL CONNECT BY LEVEL < 1000) a,  (
SELECT 123 ID ,sum(1) k1 ,sum(2) k2 ,sum(3) k3 ,sum(4) k4 ,sum(5) k5
,sum(6) k6 ,sum(7) k7 ,sum(8) k8 ,sum(9) k9 ,sum(10) k10 ,sum(11) k11
,sum(12) k12 ,sum(13) k13 ,sum(14) k14 ,sum(15) k15 ,sum(16) k16
,sum(17) k17 ,sum(18) k18 ,sum(19) k19 ,sum(20) k20 ,sum(21) k21
,sum(22) k22 ,sum(23) k23 ,sum(24) k24 ,sum(25) k25 ,sum(26) k26
,sum(27) k27 ,sum(28) k28 ,sum(29) k29 ,sum(30) k30 ,sum(31) k31
,sum(32) k32 ,sum(33) k33 ,sum(34) k34 ,sum(35) k35 ,sum(36) k36
,sum(37) k37 ,sum(38) k38 ,sum(39) k39 ,sum(40) k40 ,sum(41) k41
,sum(42) k42 ,sum(43) k43 ,sum(44) k44 ,sum(45) k45 ,sum(46) k46
,sum(47) k47 ,sum(48) k48 ,sum(49) k49 ,sum(50) k50 ,sum(51) k51
,sum(52) k52 ,sum(53) k53 ,sum(54) k54 ,sum(55) k55 ,sum(56) k56
,sum(57) k57 ,sum(58) k58 ,sum(59) k59 ,sum(60) k60 ,sum(61) k61
,sum(62) k62 ,sum(63) k63 ,sum(64) k64 ,sum(65) k65 ,sum(66) k66
,sum(67) k67 ,sum(68) k68 ,sum(69) k69 ,sum(70) k70 ,sum(71) k71
,sum(72)
Plan hash value: 2672300481
-------------------------------------------------------------------------------------------------------------------
| Id  | Operation                      | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time   |  OMem |  1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |      |        |       |     4 (100)|          |       |       |          |
|*  1 |  HASH JOIN OUTER               |      |      1 |  4631 |     4   (0)| 00:00:01 |  2293K|  2293K| 1664K (0)|
|   2 |   VIEW                         |      |      1 |    13 |     2   (0)| 00:00:01 |       |       |          |
|   3 |    CONNECT BY WITHOUT FILTERING|      |        |       |            |          |       |       |          |
|   4 |     FAST DUAL                  |      |      1 |       |     2   (0)| 00:00:01 |       |       |          |
|   5 |   VIEW                         |      |      1 |  4618 |     2   (0)| 00:00:01 |       |       |          |
|   6 |    SORT GROUP BY               |      |      1 |       |     2   (0)| 00:00:01 | 20480 | 20480 |18432  (0)|
|   7 |     FAST DUAL                  |      |      1 |       |     2   (0)| 00:00:01 |       |       |          |
-------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$1
   2 - SEL$2 / A@SEL$1
   3 - SEL$2
   4 - SEL$2 / DUAL@SEL$2
   5 - SEL$3 / B@SEL$1
   6 - SEL$3
   7 - SEL$3 / DUAL@SEL$3
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("A"."ID"="B"."ID")

--//执行计划id=6.从HASH GROUP BY变成了SORT GROUP BY.

目录
相关文章
|
2月前
|
Go
value, exists := raw["data"]
value, exists := raw["data"]
|
11月前
|
数据库
MongoError: E11000 duplicate key error collection: blog.users index: email_1 dup key
MongoError: E11000 duplicate key error collection: blog.users index: email_1 dup key
ROOT_DIR=os.path.abspath(os.path.join(p, '..', 'data/raw/'))代码含义
这行代码的作用是设置一个名为 ROOT_DIR 的变量,其值为指向项目根目录下的"data/raw/"目录的绝对路径。下面是对每个部分的详细解释: os.path.abspath():这个函数返回参数路径的绝对路径,也就是完整路径,包括盘符或根目录和所有子目录。 os.path.join(p, '..', 'data/raw/'):这个函数使用操作系统特定的路径分隔符将参数连接起来,并返回一个新的路径。这里,它连接了当前工作目录(也就是代码所在的目录)的父目录("..") 和"data/raw/",生成了一个相对路径。 p:这是一个之前定义过的变量,代表了当前工作目录的路径。 ROOT_DI
142 0
|
物联网 测试技术 索引
[20180609]Wrong Results with IOT, Added Column and Secondary Index2.txt
[20180609]Wrong Results with IOT, Added Column and Secondary Index2.txt --//链接:http://db-oriented.
1144 0
|
物联网 测试技术 索引
[20180608]Wrong Results with IOT, Added Column and Secondary Index.txt
[20180608]Wrong Results with IOT, Added Column and Secondary Index.txt --//链接:http://db-oriented.
1088 0
|
Oracle 关系型数据库 Linux
[20160323]关于FULL_HASH_VALUE2.txt
[20160323]关于FULL_HASH_VALUE2.txt --前一阵子firefox遇到问题,测试插件Calculate Hash.链接: http://blog.
915 0
|
SQL 算法 Oracle
[20160302]关于FULL_HASH_VALUE.txt
[20160302]关于FULL_HASH_VALUE.txt --昨天想给firefox安装一个计算器插件,无意中发现Calculate Hash的插件: --它是基于文件来计算MD5,SHA1,理论讲这些算法是一样的,也可以用它来计算FULL_HASH_VALUE值。
901 0