当前位置:网站首页>[20201204]为什么返回2行记录.txt

[20201204]为什么返回2行记录.txt

2020-12-08 12:07:12 程序猿欧文

[20201204]为什么返回2行记录.txt

--//在itpub问的问题 =>[20180907]访问v$视图与一致性读取.txt

1.问题提出:
SCOTT@book> @ 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

SCOTT@book> select sid from v$mystat where rownum=1;
       SID
----------
        32

SCOTT@book> select  sid ,osuser  from v$session where sid = 32;
       SID OSUSER
---------- ------------------------------
        32 oracle
--//返回1行.如果加入提示。

SCOTT@book> alter session set statistics_level = all;
Session altered.

SCOTT@book> select /*+ leading(s e w) */ sid ,osuser  from v$session where sid = 32;
       SID OSUSER
---------- ------------------------------
        32 oracle
        32 oracle

--//查看执行计划:
SCOTT@book> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  41djy6556s87h, child number 1
-------------------------------------
select /*+ leading(s e w) */ sid ,osuser  from v$session where sid = 32
Plan hash value: 1247622051
---------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                 | Name            | Starts | E-Rows |E-Bytes| Cost (%CPU)| A-Rows |   A-Time   |  OMem |  1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT          |                 |      1 |        |       |     1 (100)|      2 |00:00:00.01 |       |       |          |
|   1 |  NESTED LOOPS             |                 |      1 |      1 |   108 |     0   (0)|      2 |00:00:00.01 |       |       |          |
|   2 |   MERGE JOIN CARTESIAN    |                 |      1 |      1 |    82 |     0   (0)|   1367 |00:00:00.01 |       |       |          |
|*  3 |    FIXED TABLE FIXED INDEX| X$KSUSE (ind:1) |      1 |      1 |    69 |     0   (0)|      1 |00:00:00.01 |       |       |          |
|   4 |    BUFF.........

版权声明
本文为[程序猿欧文]所创,转载请带上原文链接,感谢
https://my.oschina.net/mikeowen/blog/4780839