手机版
你好,游客 登录 注册
背景:
阅读新闻

Oracle 12c In-Memory in Tablespaces

[日期:2015-11-11] 来源:Linux社区  作者:lucyne [字体:大 中 小]

上篇文章讲了在表级别可以开启In-Memory,其实在Tablespaces也可指定开启Tablespaces ,在Tablespaces 级别指定后,存储在这个Tablespaces 上的表也都开启了In-Memory。下面我们来测试一下。

1.建立一个表空间,并指定INMEMORY字句
SQL> CREATE TABLESPACE tbs1 datafile 'tbs1' SIZE 40M  DEFAULT INMEMORY;

2.在新建立的表空间上建立一张表,且表不指定INMEMORY
SQL> create table bmw.tt tablespace tbs1 as select * from dba_objects ;
Table created.

3.可以看到新建立的表也都开启了INMEMORY,这是因为我们在表空间级别开启了INMEMORY。
SQL> l
  1* select TABLE_NAME,INMEMORY_PRIORITY,INMEMORY_DISTRIBUTE,INMEMORY_COMPRESSION from dba_tables where table_name='TT'
SQL> /

TABLE_NAME          INMEMORY_PRIORITY        INMEMORY_DISTRIBUTE                          INMEMORY_COMPRESSION
-------------------- ------------------------ --------------------------------------------- ------------------------------
TT                  NONE                    AUTO                                          FOR QUERY LOW

SQL> l
  1  SELECT * FROM V$INMEMORY_AREA
  2*
SQL> /
POOL      ALLOC_BYTES USED_BYTES POPULATE_S    CON_ID
---------- ----------- ---------- ---------- ----------
1MB POOL    837812224    4194304 DONE                3
64KB POOL    201326592    131072 DONE                3

当表没有查询时,我们可以看到并未分配内存

4.查询表
SQL> set autot trace
SQL> SELECT * FROM bmw.tt;
90935 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 264906180
-----------------------------------------------------------------------------------
| Id  | Operation                  | Name | Rows  | Bytes | Cost (%CPU)| Time    |
-----------------------------------------------------------------------------------
|  0 | SELECT STATEMENT          |      | 90935 |    9M|    32  (16)| 00:00:01 |
|  1 |  TABLE ACCESS INMEMORY FULL| TT  | 90935 |    9M|    32  (16)| 00:00:01 |
-----------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          6  recursive calls
          0  db block gets
      7485  consistent gets
      1527  physical reads
          0  redo size
    4945264  bytes sent via SQL*Net to client
      67234  bytes received via SQL*Net from client
      6064  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      90935  rows processed


以上虽然使用了TABLE ACCESS INMEMORY FULL,但由于表未在内存中,还是产生了大量的 consistent gets


5.再查询测试一下,可以看到consistent gets降到了3
SQL> /
90935 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 264906180
-----------------------------------------------------------------------------------
| Id  | Operation                  | Name | Rows  | Bytes | Cost (%CPU)| Time    |
-----------------------------------------------------------------------------------
|  0 | SELECT STATEMENT          |      | 90935 |    9M|    32  (16)| 00:00:01 |
|  1 |  TABLE ACCESS INMEMORY FULL| TT  | 90935 |    9M|    32  (16)| 00:00:01 |
-----------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          3  consistent gets
          0  physical reads
          0  redo size
    4945264  bytes sent via SQL*Net to client
      67234  bytes received via SQL*Net from client
      6064  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      90935  rows processed
SQL> set autot off
SQL> SELECT * FROM V$INMEMORY_AREA;
POOL      ALLOC_BYTES USED_BYTES POPULATE_S    CON_ID
---------- ----------- ---------- ---------- ----------
1MB POOL    837812224    8388608 DONE                3
64KB POOL    201326592    262144 DONE                3

在V$INMEMORY_AREA视图中也可以看到已经分配了多少内存。

如果取消表空间级别的INMEMORY,可以使用 ALTER TABLESPACE tbsname NO INMEMORY 子句.

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-11/125052.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款