Oracle 12c的上市为我们带来了很多新颖、强大的功能,细数算来,有大概100左右的大大小小的新特性。在这里我们体验其中2个比较小的有关SQL的新特性:
1.TOP N 语句的实现;
2.在RMAN中执行SQL语句。
新特性1 “TOP N语句查询” 实验:
查看dba_objects表中的记录数:
SQL>
select count(object_name) from dba_objects;
COUNT(OBJECT_NAME)
------------------
90901
执行计划:
SQL>
set autot on stat
SQL>
/
COUNT(OBJECT_NAME)
------------------
90901
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4016 consistent gets
0 physical reads
0 redo size
554 bytes sent via SQL*Net to client
551 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
只取前5行的数据记录:
SQL>
select object_name from dba_objects fetch next 5 rows only;
OBJECT_NAME
--------------------------------------------------------------------------------
I_COBJ#
I_USER2
CCOL$
I_COL2
FILE$
执行计划:
Statistics
----------------------------------------------------------
539 recursive calls
0 db block gets
544 consistent gets
0 physical reads
0 redo size
643 bytes sent via SQL*Net to client
551 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
28 sorts (memory)
0 sorts (disk)
5 rows processed
我们看到consistent gets的数量相差是很大的,如果用在OLTP这种系统中,大规模的查询语句并发的情境下,TOP N语句查询的新特性还是对性能的影响有很大改善的。
新特性2 “RMAN中执行SQL语句” 实验:
既然是可以实现RMAN中执行SQL语句,那么我们不妨就用上面的两条语句进行测试,比对一下执行结果是否一致:
RMAN>
select count(object_name) from dba_objects;
COUNT(OBJECT_NAME)
------------------
90901
RMAN>
select object_name from dba_objects fetch next 5 rows only;
using target database control file instead of recovery catalog
OBJECT_NAME
--------------------------------------------------------------------------------
I_COBJ#
I_USER2
CCOL$
I_COL2
FILE$
OK!
阅读(5741) | 评论(0) | 转发(0) |