查看inmemory的表,执行计划中会有相应的标识例如全表扫描为TABLE ACCESS INMEMORY FULL,如下:
SQL> create table test1 tablespace users as select * from dba_objects;
Table created.
SQL> alter table test1 inmemory;
SQL> set autotrace on
SQL> set autotrace traceonly
SQL> select count(*) from test1;
Execution Plan
----------------------------------------------------------
Plan hash value: 3896847026
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 15 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS INMEMORY FULL| TEST1 | 72573 | 15 (0)| 00:00:01 |
-----------------------------------------------------------------------------
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
552 bytes sent via SQL*Net to client
388 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
在gv$im_segments中可以看到inmemory使用情况
SQL> col SEGMENT_NAME for a5
SQL> col POPULATE_STATUS for a10
SQL> col INMEMORY_DISTRIBUTE for a10
SQL> col INMEMORY_DUPLICATE for a20
SQL> set linesize 200
SQL> select INST_ID,SEGMENT_NAME,INMEMORY_SIZE/1024/1024,BYTES/1024/1024,BYTES_NOT_POPULATED/1024/1024,INMEMORY_DISTRIBUTE,INMEMORY_DUPLICATE,POPULATE_STATUS from gv$im_segments;
INST_ID SEGME INMEMORY_SIZE/1024/1024 BYTES/1024/1024 BYTES_NOT_POPULATED/1024/1024 INMEMORY_D INMEMORY_DUPLICATE POPULATE_S
---------- ----- ----------------------- --------------- ----------------------------- ---------- -------------------- ----------
1 TEST1 4.4375 11.015625 0 AUTO NO DUPLICATE COMPLETED
INMEMORY_SIZE:segment在in-memory中占用的内存数量,单位bytes
BYTES:在内存中展示的segment,对应的磁盘上数据量(不包括元数据块),单位bytes
BYTES_NOT_POPULATED:磁盘的segment中未填充到内存中的部分的大小,单位bytes。
结合test1表的情况就是:在硬盘上为11MB的segment,带入in-memory压缩后占用内存的大小为4.4MB,该test1表的数据还有0MB没带入到内存中。