Oracle rownum影响运行计划
今天调优一条SQL语句,因为SQL比較复杂,用autotrace非常难一眼看出哪里出了问题,直接上10046。
SELECT AB.*
FROM (SELECT A.*, rownum RN
FROM (SELECT *
from (SELECT DISTINCT (D.DEVICE_ID), F.FUNCTION_LOCATION_ID
from GG_device D,
GG_CLASSIFY_CARD C,
GG_function_location F,
GG_fl_device L,
GG_tech_object_node n,
(SELECT N.TECH_OBJECT_ID
FROM GG_TECH_OBJECT_NODE N
WHERE N.NODE_TYPE = 2
START WITH N.TECH_OBJECT_ID = 15773325
CONNECT BY PRIOR
N.TECH_OBJECT_NODE_ID = N.PARENT_ID) TAB
where F.FUNCTION_LOCATION_ID = L.FUNCTION_LOCATION_ID
and L.Device_Id = d.device_id
and d.classify_id = c.classify_id
AND EXISTS
(SELECT 1
FROM GG_TECH_OBJECT_NODE N
WHERE N.TECH_OBJECT_ID = D.DEVICE_ID
AND N.NODE_TYPE = 2)
AND D.CURRENT_STATUS = 0
AND D.IS_SHARE_DEVICE = 1
AND TAB.TECH_OBJECT_ID = D.DEVICE_ID
and n.tech_object_id = f.function_location_id
AND F.SITE_ID = 1021
AND C.ALIAS_NAME IN ('A176')
union all
SELECT DISTINCT (D.DEVICE_ID), F.FUNCTION_LOCATION_ID
FROM GG_DEVICE D,
GG_CLASSIFY_CARD C,
GG_FUNCTION_LOCATION F,
GG_tech_object_node n,
(SELECT N.TECH_OBJECT_ID
FROM GG_TECH_OBJECT_NODE N
WHERE N.NODE_TYPE = 2
START WITH N.TECH_OBJECT_ID = 15773325
CONNECT BY PRIOR
N.TECH_OBJECT_NODE_ID = N.PARENT_ID) TAB
WHERE D.CLASSIFY_ID = C.CLASSIFY_ID
AND F.FUNCTION_LOCATION_ID(+) =
D.FUNCTION_LOCATION_ID
and n.tech_object_id = f.function_location_id
AND EXISTS
(SELECT 1
FROM GG_TECH_OBJECT_NODE N
WHERE N.TECH_OBJECT_ID = D.DEVICE_ID
AND N.NODE_TYPE = 2)
AND D.CURRENT_STATUS = 0
AND D.IS_SHARE_DEVICE = 0
AND TAB.TECH_OBJECT_ID = D.DEVICE_ID
AND F.SITE_ID = 1021
AND C.ALIAS_NAME IN ('A176'))) A
WHERE ROWNUM <= 25) AB
WHERE AB.RN > 0;
已用时间: 00: 00: 05.56
----------------------------------------------------------
Plan hash value: 1124467031
---------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 18 | 67248 | 28951 (1)| 00:05:48 |
|* 1 | VIEW | | 18 | 67248 | 28951 (1)| 00:05:48 |
|* 2 | COUNT STOPKEY | | | | | |
| 3 | VIEW | | 18 | 67014 | 28951 (1)| 00:05:48 |
|* 4 | SORT ORDER BY STOPKEY | | 18 | 67014 | 28951 (1)| 00:05:48 |
| 5 | VIEW | | 18 | 67014 | 28950 (1)| 00:05:48 |
| 6 | UNION-ALL | | | | | |
| 7 | HASH UNIQUE | | 6 | 2064 | 15146 (1)| 00:03:02 |
|* 8 | HASH JOIN | | 6 | 2064 | 15145 (1)| 00:03:02 |
| 9 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 1 | 102 | 3 (0)| 00:00:01 |
| 10 | NESTED LOOPS | | 6 | 2022 | 5842 (1)| 00:01:11 |
| 11 | NESTED LOOPS SEMI | | 5 | 1175 | 5827 (1)| 00:01:10 |
| 12 | NESTED LOOPS | | 5 | 1125 | 5817 (1)| 00:01:10 |
|* 13 | HASH JOIN | | 172 | 32508 | 5645 (1)| 00:01:08 |
|* 14 | HASH JOIN | | 77 | 13629 | 5601 (1)| 00:01:08 |
|* 15 | TABLE ACCESS FULL | GG_CLASSIFY_CARD | 1 | 93 | 16 (0)| 00:00:01 |
|* 16 | TABLE ACCESS FULL | GG_DEVICE | 22527 | 1847K| 5584 (1)| 00:01:08 |
| 17 | TABLE ACCESS FULL | GG_FL_DEVICE | 74829 | 876K| 43 (3)| 00:00:01 |
|* 18 | TABLE ACCESS BY INDEX ROWID| GG_FUNCTION_LOCATION | 1 | 36 | 1 (0)| 00:00:01 |
|* 19 | INDEX UNIQUE SCAN | PK_GG_FUNCTION_LOCATION | 1 | | 0 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | IDX_TECH_NODE_ID | 482K| 4712K| 2 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID | 1 | | 2 (0)| 00:00:01 |
| 22 | VIEW | | 1762K| 11M| 9291 (1)| 00:01:52 |
|* 23 | FILTER | | | | | |
|* 24 | CONNECT BY WITH FILTERING | | | | | |
| 25 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | | | | |
|* 26 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID | 1 | 7 | 3 (0)| 00:00:01 |
|* 27 | HASH JOIN | | | | | |
| 28 | CONNECT BY PUMP | | | | | |
| 29 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 1762K| 40M| 9291 (1)| 00:01:52 |
| 30 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 1762K| 40M| 9291 (1)| 00:01:52 |
| 31 | HASH UNIQUE | | 12 | 4056 | 13804 (1)| 00:02:46 |
|* 32 | HASH JOIN | | 12 | 4056 | 13803 (1)| 00:02:46 |
| 33 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 1 | 102 | 3 (0)| 00:00:01 |
| 34 | NESTED LOOPS | | 11 | 3641 | 4501 (1)| 00:00:55 |
| 35 | NESTED LOOPS SEMI | | 10 | 2290 | 4471 (1)| 00:00:54 |
|* 36 | HASH JOIN | | 10 | 2190 | 4451 (1)| 00:00:54 |
|* 37 | TABLE ACCESS FULL | GG_CLASSIFY_CARD | 1 | 93 | 16 (0)| 00:00:01 |
|* 38 | TABLE ACCESS BY INDEX ROWID| GG_DEVICE | 4 | 360 | 5 (0)| 00:00:01 |
| 39 | NESTED LOOPS | | 2823 | 347K| 4434 (1)| 00:00:54 |
|* 40 | TABLE ACCESS FULL | GG_FUNCTION_LOCATION | 685 | 24660 | 2214 (1)| 00:00:27 |
|* 41 | INDEX RANGE SCAN | IDX_FLOCID | 4 | | 2 (0)| 00:00:01 |
|* 42 | INDEX RANGE SCAN | IDX_TECH_NODE_ID | 482K| 4712K| 2 (0)| 00:00:01 |
|* 43 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID | 1 | | 2 (0)| 00:00:01 |
| 44 | VIEW | | 1762K| 11M| 9291 (1)| 00:01:52 |
|* 45 | FILTER | | | | | |
|* 46 | CONNECT BY WITH FILTERING | | | | | |
| 47 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | | | | |
|* 48 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID | 1 | 7 | 3 (0)| 00:00:01 |
|* 49 | HASH JOIN | | | | | |
| 50 | CONNECT BY PUMP | | | | | |
| 51 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 1762K| 40M| 9291 (1)| 00:01:52 |
| 52 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 1762K| 40M| 9291 (1)| 00:01:52 |
---------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("AB"."RN">0)
2 - filter(ROWNUM<=25)
4 - filter(ROWNUM<=25)
8 - access("TAB"."TECH_OBJECT_ID"="D"."DEVICE_ID")
13 - access("L"."DEVICE_ID"="D"."DEVICE_ID")
14 - access("D"."CLASSIFY_ID"="C"."CLASSIFY_ID")
15 - filter("C"."ALIAS_NAME"='A176')
16 - filter("D"."IS_SHARE_DEVICE"=1 AND "D"."CURRENT_STATUS"=0)
18 - filter("F"."SITE_ID"=1021)
19 - access("F"."FUNCTION_LOCATION_ID"="L"."FUNCTION_LOCATION_ID")
20 - access("N"."TECH_OBJECT_ID"="D"."DEVICE_ID" AND "N"."NODE_TYPE"=2)
21 - access("N"."TECH_OBJECT_ID"="F"."FUNCTION_LOCATION_ID")
23 - filter("N"."NODE_TYPE"=2)
24 - filter("N"."TECH_OBJECT_ID"=15773325)
26 - access("N"."TECH_OBJECT_ID"=15773325)
27 - access("N"."PARENT_ID"=NULL)
32 - access("TAB"."TECH_OBJECT_ID"="D"."DEVICE_ID")
36 - access("D"."CLASSIFY_ID"="C"."CLASSIFY_ID")
37 - filter("C"."ALIAS_NAME"='A176')
38 - filter("D"."IS_SHARE_DEVICE"=0 AND "D"."CURRENT_STATUS"=0)
40 - filter("F"."SITE_ID"=1021)
41 - access("F"."FUNCTION_LOCATION_ID"="D"."FUNCTION_LOCATION_ID")
42 - access("N"."TECH_OBJECT_ID"="D"."DEVICE_ID" AND "N"."NODE_TYPE"=2)
43 - access("N"."TECH_OBJECT_ID"="F"."FUNCTION_LOCATION_ID")
45 - filter("N"."NODE_TYPE"=2)
46 - filter("N"."TECH_OBJECT_ID"=15773325)
48 - access("N"."TECH_OBJECT_ID"=15773325)
49 - access("N"."PARENT_ID"=NULL)
统计信息
----------------------------------------------------------
9 recursive calls
0 db block gets
209163 consistent gets
0 physical reads
0 redo size
2890 bytes sent via SQL*Net to client
10811 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
63 sorts (memory)
0 sorts (disk)
1 rows processed
10046 trace的结果,能够一眼看出是递归出了问题,依照业务上来说一个节点以下没有多少数据啊,怎么会不走索引呢?
Rows Row Source Operation
------- ---------------------------------------------------
1 VIEW (cr=209038 pr=0 pw=0 time=5665797 us)
1 COUNT STOPKEY (cr=209038 pr=0 pw=0 time=5665774 us)
1 VIEW (cr=209038 pr=0 pw=0 time=5665768 us)
1 SORT ORDER BY STOPKEY (cr=209038 pr=0 pw=0 time=5665745 us)
1 VIEW (cr=209038 pr=0 pw=0 time=5665649 us)
1 UNION-ALL (cr=209038 pr=0 pw=0 time=5665631 us)
0 HASH UNIQUE (cr=25205 pr=0 pw=0 time=570538 us)
0 HASH JOIN (cr=25205 pr=0 pw=0 time=570360 us)
0 TABLE ACCESS BY INDEX ROWID GG_TECH_OBJECT_NODE (cr=25205 pr=0 pw=0 time=570095 us)
1 NESTED LOOPS (cr=25205 pr=0 pw=0 time=570075 us)
0 NESTED LOOPS SEMI (cr=25205 pr=0 pw=0 time=570069 us)
0 NESTED LOOPS (cr=25205 pr=0 pw=0 time=570066 us)
0 HASH JOIN (cr=25205 pr=0 pw=0 time=570062 us)
0 HASH JOIN (cr=25205 pr=0 pw=0 time=569617 us)
1 TABLE ACCESS FULL GG_CLASSIFY_CARD (cr=68 pr=0 pw=0 time=1467 us)
21206 TABLE ACCESS FULL GG_DEVICE (cr=25137 pr=0 pw=0 time=424214 us)
0 TABLE ACCESS FULL GG_FL_DEVICE (cr=0 pr=0 pw=0 time=0 us)
0 TABLE ACCESS BY INDEX ROWID GG_FUNCTION_LOCATION (cr=0 pr=0 pw=0 time=0 us)
0 INDEX UNIQUE SCAN PK_GG_FUNCTION_LOCATION (cr=0 pr=0 pw=0 time=0 us)(object id 508068)
0 INDEX RANGE SCAN IDX_TECH_NODE_ID (cr=0 pr=0 pw=0 time=0 us)(object id 541613)
0 INDEX RANGE SCAN IDX_TECH_OBJECT_ID (cr=0 pr=0 pw=0 time=0 us)(object id 508645)
0 VIEW (cr=0 pr=0 pw=0 time=0 us)
0 FILTER (cr=0 pr=0 pw=0 time=0 us)
0 CONNECT BY WITH FILTERING (cr=0 pr=0 pw=0 time=0 us)
0 TABLE ACCESS BY INDEX ROWID GG_TECH_OBJECT_NODE (cr=0 pr=0 pw=0 time=0 us)
0 INDEX RANGE SCAN IDX_TECH_OBJECT_ID (cr=0 pr=0 pw=0 time=0 us)(object id 508645)
0 HASH JOIN (cr=0 pr=0 pw=0 time=0 us)
0 CONNECT BY PUMP (cr=0 pr=0 pw=0 time=0 us)
0 TABLE ACCESS FULL GG_TECH_OBJECT_NODE (cr=0 pr=0 pw=0 time=0 us)
0 TABLE ACCESS FULL GG_TECH_OBJECT_NODE (cr=0 pr=0 pw=0 time=0 us)
1 HASH UNIQUE (cr=183833 pr=0 pw=0 time=5095035 us)
1 HASH JOIN (cr=183748 pr=0 pw=0 time=5090111 us)
170 TABLE ACCESS BY INDEX ROWID GG_TECH_OBJECT_NODE (cr=15772 pr=0 pw=0 time=7653 us)
341 NESTED LOOPS (cr=15610 pr=0 pw=0 time=189743 us)
170 NESTED LOOPS SEMI (cr=15268 pr=0 pw=0 time=5170 us)
170 HASH JOIN (cr=14926 pr=0 pw=0 time=3232 us)
1 TABLE ACCESS FULL GG_CLASSIFY_CARD (cr=68 pr=0 pw=0 time=830 us)
2867 TABLE ACCESS BY INDEX ROWID GG_DEVICE (cr=14858 pr=0 pw=0 time=28976 us)
4728 NESTED LOOPS (cr=13282 pr=0 pw=0 time=94565 us)
1667 TABLE ACCESS FULL GG_FUNCTION_LOCATION (cr=9937 pr=0 pw=0 time=13539 us)
3060 INDEX RANGE SCAN IDX_FLOCID (cr=3345 pr=0 pw=0 time=12458 us)(object id 507929)
170 INDEX RANGE SCAN IDX_TECH_NODE_ID (cr=342 pr=0 pw=0 time=3171 us)(object id 541613)
170 INDEX RANGE SCAN IDX_TECH_OBJECT_ID (cr=342 pr=0 pw=0 time=1854 us)(object id 508645)
31 VIEW (cr=167976 pr=0 pw=0 time=4864861 us)
31 FILTER (cr=167976 pr=0 pw=0 time=4864794 us)
56 CONNECT BY WITH FILTERING (cr=167976 pr=0 pw=0 time=4865653 us)
1 TABLE ACCESS BY INDEX ROWID GG_TECH_OBJECT_NODE (cr=4 pr=0 pw=0 time=58 us)
1 INDEX RANGE SCAN IDX_TECH_OBJECT_ID (cr=3 pr=0 pw=0 time=25 us)(object id 508645)
55 HASH JOIN (cr=167972 pr=0 pw=0 time=1264029 us)
56 CONNECT BY PUMP (cr=0 pr=0 pw=0 time=56 us)
7048956 TABLE ACCESS FULL GG_TECH_OBJECT_NODE (cr=167972 pr=0 pw=0 time=488 us)
0 TABLE ACCESS FULL GG_TECH_OBJECT_NODE (cr=0 pr=0 pw=0 time=0 us)
在无意中測试发现,去掉分页的语句之后,就很快了。揣測是COUNT STOPKEY造成的,假设数据量大的做分页,肯定是能够提升性能的,但此条SQL语句仅仅是返回一条数据。我的结论是rownum能够改变运行计划。
SQL> SELECT *
from (SELECT DISTINCT (D.DEVICE_ID), F.FUNCTION_LOCATION_ID
from GG_device D,
GG_CLASSIFY_CARD C,
GG_function_location F,
GG_fl_device L,
GG_tech_object_node n,
(SELECT N.TECH_OBJECT_ID
FROM GG_TECH_OBJECT_NODE N
WHERE N.NODE_TYPE = 2
START WITH N.TECH_OBJECT_ID = 15773325
CONNECT BY PRIOR N.TECH_OBJECT_NODE_ID = N.PARENT_ID) TAB
where F.FUNCTION_LOCATION_ID = L.FUNCTION_LOCATION_ID
and L.Device_Id = d.device_id
and d.classify_id = c.classify_id
AND EXISTS (SELECT 1
FROM GG_TECH_OBJECT_NODE N
WHERE N.TECH_OBJECT_ID = D.DEVICE_ID
AND N.NODE_TYPE = 2)
AND D.CURRENT_STATUS = 0
AND D.IS_SHARE_DEVICE = 1
AND TAB.TECH_OBJECT_ID = D.DEVICE_ID
and n.tech_object_id = f.function_location_id
AND F.SITE_ID = 1021
AND C.ALIAS_NAME IN ('A176')
union all
SELECT DISTINCT (D.DEVICE_ID), F.FUNCTION_LOCATION_ID
FROM GG_DEVICE D,
GG_CLASSIFY_CARD C,
GG_FUNCTION_LOCATION F,
GG_tech_object_node n,
(SELECT N.TECH_OBJECT_ID
FROM GG_TECH_OBJECT_NODE N
WHERE N.NODE_TYPE = 2
START WITH N.TECH_OBJECT_ID = 15773325
CONNECT BY PRIOR N.TECH_OBJECT_NODE_ID = N.PARENT_ID) TAB
WHERE D.CLASSIFY_ID = C.CLASSIFY_ID
AND F.FUNCTION_LOCATION_ID(+) = D.FUNCTION_LOCATION_ID
and n.tech_object_id = f.function_location_id
AND EXISTS (SELECT 1
FROM GG_TECH_OBJECT_NODE N
WHERE N.TECH_OBJECT_ID = D.DEVICE_ID
AND N.NODE_TYPE = 2)
AND D.CURRENT_STATUS = 0
AND D.IS_SHARE_DEVICE = 0
AND TAB.TECH_OBJECT_ID = D.DEVICE_ID
AND F.SITE_ID = 1021
AND C.ALIAS_NAME IN ('A176'));
已用时间: 00: 00: 00.06
运行计划
----------------------------------------------------------
Plan hash value: 1345020195
------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 7446 | 41 (5)| 00:00:01 |
| 1 | VIEW | | 2 | 7446 | 41 (5)| 00:00:01 |
| 2 | UNION-ALL | | | | | |
| 3 | HASH UNIQUE | | 1 | 345 | 21 (5)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 1 | 103 | 3 (0)| 00:00:01 |
| 5 | NESTED LOOPS | | 1 | 345 | 20 (0)| 00:00:01 |
| 6 | NESTED LOOPS | | 1 | 242 | 17 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 206 | 16 (0)| 00:00:01 |
| 8 | NESTED LOOPS SEMI | | 1 | 194 | 15 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 184 | 13 (0)| 00:00:01 |
| 10 | NESTED LOOPS | | 3 | 273 | 10 (0)| 00:00:01 |
| 11 | VIEW | | 3 | 21 | 6 (0)| 00:00:01 |
|* 12 | FILTER | | | | | |
|* 13 | CONNECT BY WITH FILTERING | | | | | |
| 14 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | | | | |
|* 15 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | 7 | 3 (0)| 00:00:01 |
| 16 | NESTED LOOPS | | | | | |
| 17 | BUFFER SORT | | | | | |
| 18 | CONNECT BY PUMP | | | | | |
| 19 | TABLE ACCESS BY INDEX ROWID| GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | IDX_TECH_OBJECT_PARENT_ID1 | 3 | | 3 (0)| 00:00:01 |
|* 21 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 22 | TABLE ACCESS BY INDEX ROWID | GG_DEVICE | 1 | 84 | 2 (0)| 00:00:01 |
|* 23 | INDEX UNIQUE SCAN | PK_GG_DEVICE | 1 | | 1 (0)| 00:00:01 |
|* 24 | TABLE ACCESS BY INDEX ROWID | GG_CLASSIFY_CARD | 1 | 93 | 1 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | SYS_C00468549 | 1 | | 0 (0)| 00:00:01 |
|* 26 | INDEX RANGE SCAN | IDX_TECH_NODE_ID1 | 587K| 5736K| 2 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | PK_GG_FL_DEVICE | 2 | 24 | 1 (0)| 00:00:01 |
|* 28 | TABLE ACCESS BY INDEX ROWID | GG_FUNCTION_LOCATION | 1 | 36 | 1 (0)| 00:00:01 |
|* 29 | INDEX UNIQUE SCAN | PK_GG_FUNCTION_LOCATION | 1 | | 0 (0)| 00:00:01 |
|* 30 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | | 2 (0)| 00:00:01 |
| 31 | HASH UNIQUE | | 1 | 339 | 20 (5)| 00:00:01 |
| 32 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 1 | 103 | 3 (0)| 00:00:01 |
| 33 | NESTED LOOPS | | 1 | 339 | 19 (0)| 00:00:01 |
| 34 | NESTED LOOPS SEMI | | 1 | 236 | 16 (0)| 00:00:01 |
| 35 | NESTED LOOPS | | 1 | 226 | 14 (0)| 00:00:01 |
| 36 | NESTED LOOPS | | 1 | 133 | 13 (0)| 00:00:01 |
| 37 | NESTED LOOPS | | 3 | 291 | 10 (0)| 00:00:01 |
| 38 | VIEW | | 3 | 21 | 6 (0)| 00:00:01 |
|* 39 | FILTER | | | | | |
|* 40 | CONNECT BY WITH FILTERING | | | | | |
| 41 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | | | | |
|* 42 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | 7 | 3 (0)| 00:00:01 |
| 43 | NESTED LOOPS | | | | | |
| 44 | BUFFER SORT | | | | | |
| 45 | CONNECT BY PUMP | | | | | |
| 46 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 47 | INDEX RANGE SCAN | IDX_TECH_OBJECT_PARENT_ID1 | 3 | | 3 (0)| 00:00:01 |
|* 48 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 49 | TABLE ACCESS BY INDEX ROWID | GG_DEVICE | 1 | 90 | 2 (0)| 00:00:01 |
|* 50 | INDEX UNIQUE SCAN | PK_GG_DEVICE | 1 | | 1 (0)| 00:00:01 |
|* 51 | TABLE ACCESS BY INDEX ROWID | GG_FUNCTION_LOCATION | 1 | 36 | 1 (0)| 00:00:01 |
|* 52 | INDEX UNIQUE SCAN | PK_GG_FUNCTION_LOCATION | 1 | | 0 (0)| 00:00:01 |
|* 53 | TABLE ACCESS BY INDEX ROWID | GG_CLASSIFY_CARD | 1 | 93 | 1 (0)| 00:00:01 |
|* 54 | INDEX UNIQUE SCAN | SYS_C00468549 | 1 | | 0 (0)| 00:00:01 |
|* 55 | INDEX RANGE SCAN | IDX_TECH_NODE_ID1 | 587K| 5736K| 2 (0)| 00:00:01 |
|* 56 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | | 2 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
12 - filter("N"."NODE_TYPE"=2)
13 - filter("N"."TECH_OBJECT_ID"=15773325)
15 - access("N"."TECH_OBJECT_ID"=15773325)
20 - access("N"."PARENT_ID"=NULL)
21 - access("N"."PARENT_ID"=NULL)
22 - filter("D"."IS_SHARE_DEVICE"=1 AND "D"."CURRENT_STATUS"=0)
23 - access("TAB"."TECH_OBJECT_ID"="D"."DEVICE_ID")
24 - filter("C"."ALIAS_NAME"='A176')
25 - access("D"."CLASSIFY_ID"="C"."CLASSIFY_ID")
26 - access("N"."TECH_OBJECT_ID"="D"."DEVICE_ID" AND "N"."NODE_TYPE"=2)
27 - access("L"."DEVICE_ID"="D"."DEVICE_ID")
28 - filter("F"."SITE_ID"=1021)
29 - access("F"."FUNCTION_LOCATION_ID"="L"."FUNCTION_LOCATION_ID")
30 - access("N"."TECH_OBJECT_ID"="F"."FUNCTION_LOCATION_ID")
39 - filter("N"."NODE_TYPE"=2)
40 - filter("N"."TECH_OBJECT_ID"=15773325)
42 - access("N"."TECH_OBJECT_ID"=15773325)
47 - access("N"."PARENT_ID"=NULL)
48 - access("N"."PARENT_ID"=NULL)
49 - filter("D"."IS_SHARE_DEVICE"=0 AND "D"."CURRENT_STATUS"=0)
50 - access("TAB"."TECH_OBJECT_ID"="D"."DEVICE_ID")
51 - filter("F"."SITE_ID"=1021)
52 - access("F"."FUNCTION_LOCATION_ID"="D"."FUNCTION_LOCATION_ID")
53 - filter("C"."ALIAS_NAME"='A176')
54 - access("D"."CLASSIFY_ID"="C"."CLASSIFY_ID")
55 - access("N"."TECH_OBJECT_ID"="D"."DEVICE_ID" AND "N"."NODE_TYPE"=2)
56 - access("N"."TECH_OBJECT_ID"="F"."FUNCTION_LOCATION_ID")
统计信息
----------------------------------------------------------
7 recursive calls
0 db block gets
738 consistent gets
0 physical reads
0 redo size
2606 bytes sent via SQL*Net to client
10273 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
18 sorts (memory)
0 sorts (disk)
1 rows processed
用还有一种方式实现分页。
SELECT AB.*
FROM (SELECT tt.*,row_number()over(ORDER BY SORT_NO, name) nr
from (SELECT DISTINCT (D.DEVICE_ID),
D.NAME,
N.Full_Path SORT_NO,
F.FUNCTION_LOCATION_ID
from GG_device D,
GG_CLASSIFY_CARD C,
GG_function_location F,
GG_fl_device L,
GG_tech_object_node n,
(SELECT N.TECH_OBJECT_ID
FROM GG_TECH_OBJECT_NODE N
WHERE N.NODE_TYPE = 2
START WITH N.TECH_OBJECT_ID = 15773325
CONNECT BY PRIOR
N.TECH_OBJECT_NODE_ID = N.PARENT_ID) TAB
where F.FUNCTION_LOCATION_ID =
L.FUNCTION_LOCATION_ID
and L.Device_Id = d.device_id
and d.classify_id = c.classify_id
AND EXISTS
(SELECT 1
FROM GG_TECH_OBJECT_NODE N
WHERE N.TECH_OBJECT_ID = D.DEVICE_ID
AND N.NODE_TYPE = 2)
AND D.CURRENT_STATUS = 0
AND D.IS_SHARE_DEVICE = 1
AND TAB.TECH_OBJECT_ID = D.DEVICE_ID
and n.tech_object_id = f.function_location_id
AND F.SITE_ID = 1021
AND C.ALIAS_NAME IN ('A176')
union all
SELECT DISTINCT (D.DEVICE_ID),
D.NAME,
N.Full_Path SORT_NO,
F.FUNCTION_LOCATION_ID
FROM GG_DEVICE D,
GG_CLASSIFY_CARD C,
GG_FUNCTION_LOCATION F,
GG_tech_object_node n,
(SELECT N.TECH_OBJECT_ID
FROM GG_TECH_OBJECT_NODE N
WHERE N.NODE_TYPE = 2
START WITH N.TECH_OBJECT_ID = 15773325
CONNECT BY PRIOR
N.TECH_OBJECT_NODE_ID = N.PARENT_ID) TAB
WHERE D.CLASSIFY_ID = C.CLASSIFY_ID
AND F.FUNCTION_LOCATION_ID(+) =
D.FUNCTION_LOCATION_ID
and n.tech_object_id = f.function_location_id
AND EXISTS
(SELECT 1
FROM GG_TECH_OBJECT_NODE N
WHERE N.TECH_OBJECT_ID = D.DEVICE_ID
AND N.NODE_TYPE = 2)
AND D.CURRENT_STATUS = 0
AND D.IS_SHARE_DEVICE = 0
AND TAB.TECH_OBJECT_ID = D.DEVICE_ID
AND F.SITE_ID = 1021
AND C.ALIAS_NAME IN ('A176')) tt
) AB where ab.nr between 1 and 25;
已用时间: 00: 00: 00.06
运行计划
----------------------------------------------------------
Plan hash value: 3880620066
--------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 7472 | 42 (8)| 00:00:01 |
|* 1 | VIEW | | 2 | 7472 | 42 (8)| 00:00:01 |
|* 2 | WINDOW SORT PUSHED RANK | | 2 | 7446 | 42 (8)| 00:00:01 |
| 3 | VIEW | | 2 | 7446 | 41 (5)| 00:00:01 |
| 4 | UNION-ALL | | | | | |
| 5 | HASH UNIQUE | | 1 | 345 | 21 (5)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 1 | 103 | 3 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 345 | 20 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 242 | 17 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 206 | 16 (0)| 00:00:01 |
| 10 | NESTED LOOPS SEMI | | 1 | 194 | 15 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 254 | 13 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 3 | 273 | 10 (0)| 00:00:01 |
| 13 | VIEW | | 3 | 21 | 6 (0)| 00:00:01 |
|* 14 | FILTER | | | | | |
|* 15 | CONNECT BY WITH FILTERING | | | | | |
| 16 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | | | | |
|* 17 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | 7 | 3 (0)| 00:00:01 |
| 25 | NESTED LOOPS | | | | | |
| 19 | BUFFER SORT | | | | | |
| 20 | CONNECT BY PUMP | | | | | |
| 21 | TABLE ACCESS BY INDEX ROWID| GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 22 | INDEX RANGE SCAN | IDX_TECH_OBJECT_PARENT_ID1 | 3 | | 3 (0)| 00:00:01 |
|* 23 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 24 | TABLE ACCESS BY INDEX ROWID | GG_DEVICE | 1 | 84 | 2 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | PK_GG_DEVICE | 1 | | 1 (0)| 00:00:01 |
|* 26 | TABLE ACCESS BY INDEX ROWID | GG_CLASSIFY_CARD | 1 | 93 | 1 (0)| 00:00:01 |
|* 27 | INDEX UNIQUE SCAN | SYS_C00468549 | 1 | | 0 (0)| 00:00:01 |
|* 28 | INDEX RANGE SCAN | IDX_TECH_NODE_ID1 | 587K| 5736K| 2 (0)| 00:00:01 |
|* 29 | INDEX RANGE SCAN | PK_GG_FL_DEVICE | 2 | 24 | 1 (0)| 00:00:01 |
|* 30 | TABLE ACCESS BY INDEX ROWID | GG_FUNCTION_LOCATION | 1 | 36 | 1 (0)| 00:00:01 |
|* 31 | INDEX UNIQUE SCAN | PK_GG_FUNCTION_LOCATION | 1 | | 0 (0)| 00:00:01 |
|* 32 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | | 2 (0)| 00:00:01 |
| 33 | HASH UNIQUE | | 1 | 339 | 20 (5)| 00:00:01 |
| 34 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 1 | 103 | 3 (0)| 00:00:01 |
| 35 | NESTED LOOPS | | 1 | 339 | 19 (0)| 00:00:01 |
| 36 | NESTED LOOPS SEMI | | 1 | 236 | 16 (0)| 00:00:01 |
| 37 | NESTED LOOPS | | 1 | 226 | 14 (0)| 00:00:01 |
| 38 | NESTED LOOPS | | 1 | 133 | 13 (0)| 00:00:01 |
| 39 | NESTED LOOPS | | 3 | 291 | 10 (0)| 00:00:01 |
| 40 | VIEW | | 3 | 21 | 6 (0)| 00:00:01 |
|* 41 | FILTER | | | | | |
|* 42 | CONNECT BY WITH FILTERING | | | | | |
| 43 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | | | | |
|* 44 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | 7 | 3 (0)| 00:00:01 |
| 45 | NESTED LOOPS | | | | | |
| 46 | BUFFER SORT | | | | | |
| 47 | CONNECT BY PUMP | | | | | |
| 48 | TABLE ACCESS BY INDEX ROWID | GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 49 | INDEX RANGE SCAN | IDX_TECH_OBJECT_PARENT_ID1 | 3 | | 3 (0)| 00:00:01 |
|* 50 | TABLE ACCESS FULL | GG_TECH_OBJECT_NODE | 3 | 72 | 6 (0)| 00:00:01 |
|* 51 | TABLE ACCESS BY INDEX ROWID | GG_DEVICE | 1 | 90 | 2 (0)| 00:00:01 |
|* 52 | INDEX UNIQUE SCAN | PK_GG_DEVICE | 1 | | 1 (0)| 00:00:01 |
|* 53 | TABLE ACCESS BY INDEX ROWID | GG_FUNCTION_LOCATION | 1 | 36 | 1 (0)| 00:00:01 |
|* 54 | INDEX UNIQUE SCAN | PK_GG_FUNCTION_LOCATION | 1 | | 0 (0)| 00:00:01 |
|* 55 | TABLE ACCESS BY INDEX ROWID | GG_CLASSIFY_CARD | 1 | 93 | 1 (0)| 00:00:01 |
|* 56 | INDEX UNIQUE SCAN | SYS_C00468549 | 1 | | 0 (0)| 00:00:01 |
|* 57 | INDEX RANGE SCAN | IDX_TECH_NODE_ID1 | 587K| 5736K| 2 (0)| 00:00:01 |
|* 58 | INDEX RANGE SCAN | IDX_TECH_OBJECT_ID1 | 1 | | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("AB"."NR">=1 AND "AB"."NR"<=25)
2 - filter(ROW_NUMBER() OVER ( ORDER BY "SORT_NO","NAME")<=25)
14 - filter("N"."NODE_TYPE"=2 AND 1<=25)
15 - filter("N"."TECH_OBJECT_ID"=15773325)
17 - access("N"."TECH_OBJECT_ID"=15773325)
22 - access("N"."PARENT_ID"=NULL)
23 - access("N"."PARENT_ID"=NULL)
24 - filter("D"."IS_SHARE_DEVICE"=1 AND "D"."CURRENT_STATUS"=0)
25 - access("TAB"."TECH_OBJECT_ID"="D"."DEVICE_ID")
26 - filter("C"."ALIAS_NAME"='A176')
27 - access("D"."CLASSIFY_ID"="C"."CLASSIFY_ID")
28 - access("N"."TECH_OBJECT_ID"="D"."DEVICE_ID" AND "N"."NODE_TYPE"=2)
29 - access("L"."DEVICE_ID"="D"."DEVICE_ID")
30 - filter("F"."SITE_ID"=1021)
31 - access("F"."FUNCTION_LOCATION_ID"="L"."FUNCTION_LOCATION_ID")
32 - access("N"."TECH_OBJECT_ID"="F"."FUNCTION_LOCATION_ID")
41 - filter("N"."NODE_TYPE"=2 AND 1<=25)
42 - filter("N"."TECH_OBJECT_ID"=15773325)
44 - access("N"."TECH_OBJECT_ID"=15773325)
49 - access("N"."PARENT_ID"=NULL)
50 - access("N"."PARENT_ID"=NULL)
51 - filter("D"."IS_SHARE_DEVICE"=0 AND "D"."CURRENT_STATUS"=0)
52 - access("TAB"."TECH_OBJECT_ID"="D"."DEVICE_ID")
53 - filter("F"."SITE_ID"=1021)
54 - access("F"."FUNCTION_LOCATION_ID"="D"."FUNCTION_LOCATION_ID")
55 - filter("C"."ALIAS_NAME"='A176')
56 - access("D"."CLASSIFY_ID"="C"."CLASSIFY_ID")
57 - access("N"."TECH_OBJECT_ID"="D"."DEVICE_ID" AND "N"."NODE_TYPE"=2)
58 - access("N"."TECH_OBJECT_ID"="F"."FUNCTION_LOCATION_ID")
统计信息
----------------------------------------------------------
8 recursive calls
0 db block gets
863 consistent gets
0 physical reads
0 redo size
2890 bytes sent via SQL*Net to client
10807 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
76 sorts (memory)
0 sorts (disk)
1 rows processed
Oracle rownum影响运行计划的更多相关文章
- 使用hint优化Oracle的运行计划 以及 SQL Tune Advisor的使用
背景: 某表忽然出现查询很缓慢的情况.cost 100+ 秒以上:严重影响生产. 原SQL: explain plan for select * from ( select ID id,RET_NO ...
- [Oracle] 获取运行计划的各方法总结
总的结论: 一.获取运行计划的6种方法(具体步骤已经在每一个样例的开头凝视部分说明了): 1. explain plan for获取: 2. set autotrace on . 3. stati ...
- Oracle 11g 递归+ exists运行计划的改变
有一个递归查询在10g上执行非常快,但在11g上执行不出来. SQL> select * from v$version; BANNER ----------------------------- ...
- oracle分区表运行计划
分区表有非常多优点,以大化小,一小化了,加上并行的使用,在loap中能往往能提高几十倍甚至几百倍的效果. 当然表设计得不好也会适得其反.效果比普通表跟糟糕. 为了更好的使用分区表,这里看一下分区表的运 ...
- Oracle中的执行计划
使用autotrace sqlplus系统参数:SQL> set autotrace trace onSQL> select * from dual;DUM---XExecution Pl ...
- MySQL运行计划初探
-Mysql运行计划总结– 1 运行计划概述 先看看一个运行计划 mysql> explain SELECT * FROM EMP , DAO_OBJECTS t1 , DAO_OBJECTS ...
- 闪回drop恢复表后sql运行计划异常
-----正常运行计划 set autotrace traceonly set linesize 1000 select /*+index(t idx_object_id)*/ * from t wh ...
- Spark入门实战系列--6.SparkSQL(中)--深入了解SparkSQL运行计划及调优
[注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 1.1 运行环境说明 1.1.1 硬软件环境 线程,主频2.2G,10G内存 l 虚拟软 ...
- Oracle中获取执行计划的几种方法分析
以下是对Oracle中获取执行计划的几种方法进行了详细的分析介绍,需要的朋友可以参考下 1. 预估执行计划 - Explain PlanExplain plan以SQL语句作为输入,得到这条S ...
随机推荐
- python--(爬虫-re模块)
python--(爬虫-re模块) re模块四大核心功能: 1.findall 查找所有,返回list import re lst = re.findall("m", " ...
- webpack操作基础
webpack 是一个前端加载/打包工具,根据模块的依赖关系进行静态分析,并依根据规则生成对应的静态资源
- mysql存储小数
线下不知道什么版本的古董了,经本人亲测,varchar类型的数据,可以直接执行mysql的sum函数. ________________________________________________ ...
- idea 编辑器 光标问题!(insert键)
今天写代码不小心按了键盘的insert键,光标莫名闪退了 ,重新打开的时候发现 光标变成了 按了insert 的效果 ,简直无语的要命啊! 这敲代码太恶心了!怒搜资料 结果找到了解决办法! 1.打 ...
- 【Codeforces Round #483 (Div. 2) C】Finite or not?
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 有个性质. 如果p/q是分数的最简形式. 那么p/q能化成有限小数. 当且仅当q的质因数分解形式中只有质因子2和5 (且不能出现其他 ...
- iOS开发自己定义键盘回车键Return Key
在iOS开发中.用户在进行文本输入的时候,往往会用到虚拟键盘上的回车键,也就是Return Key.回车键有时候能够是"完毕"(表示输入结束).能够是"下一项" ...
- bzoj 1600 & Usaco 月赛 2008 建造栅栏 题解
[原题] 1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 785 Solved: 443 [Subm ...
- Java类载入器
1. 系统载入器简单介绍 Java虚拟机中能够安装多个类载入器,系统默认三个主要类载入器(BootStrap.ExtClassLoader.AppClassLoader).每一个类载入器负责载入特 ...
- 第二次phython作业
第一题:编写程序,生成一个包含50个随机整数的列表,然后删除其中所有奇数.(注意保证删除操作的效率) import random x=[random.randint(0,100)for i in ra ...
- iOS开发- 生成/解析.vcf文件
vcf, 通讯录导出的一种格式. 一.生成vcf文件 假设要把我们iPhone通讯录里的数据, 生成vcf格式文件. 我们能够借助iCloud. 小技巧:通过iCloud导出iPhone通讯录的方法 ...