Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions in-memory-21c/aim-high/aim-high.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Automatic In-Memory High
# Automatic In-Memory Level High

## Introduction
Watch the video below to get an overview of Automatic In-Memory:
Expand Down Expand Up @@ -31,9 +31,7 @@ In Oracle Database 18c a feature called Automatic In-Memory (AIM) was added. The
This Lab will explore the new AIM level HIGH and how it works. A new schema will be used, the AIM schema with small, medium and large tables. This will make it easier to show how AIM works as the column store experiences "memory pressure" (i.e. gets full). The LINEORDER table in the SSB schema will be used to help "fill up" the IM column store and then the AIM tables will be used to show how AIM can manage the total number of objects for maximum benefit.


## Task 1: Verify Directory Definitions

In this Lab we will be populating external data from a local directory and we will need to define a database directory to use in our external table definitions to point the database to our external data.
## Task 1: AIM Level High

Let's switch to the aim-high folder and log back in to the PDB:

Expand Down Expand Up @@ -320,7 +318,7 @@ SQL>
SQL>
```

Verify that all of the LINEORDER partitions are populated before continuing on with the lab.
Verify that all of the LINEORDER partitions are populated before continuing on with the lab. You may have to re-run this script to verify that the partitions are populated since it does take a little bit of time to fully populate the partitions.

5. Let's re-check the inmemory status of the objects in the SSB and AIM schemas:

Expand Down Expand Up @@ -807,7 +805,7 @@ SQL>
SQL>
```

11. Let's take a look at the Heat Map statistics for the segments.
11. Let's take a look at the Heat Map statistics for the segments. Although Heat Map is not used directly by AIM, and does not have to be enabled for AIM to work, it does give us an easy way to look at the usage statistics that AIM does base its decisions on.

Run the script *11\_hm\_stats.sql*

Expand Down Expand Up @@ -889,6 +887,8 @@ SQL>
SQL>
```

Note that your values may be different than what is shown above. The values shown will be based on the usage that has occurred in your database.

12. Now let's see if we can figure out what has happened with the AIM processing. First we will look at the tasks that are running as part of AIM.

Run the script *12\_aim\_tasks.sql*
Expand Down Expand Up @@ -932,7 +932,7 @@ SQL>
SQL>
```

Make note of the last task_id. We will use this as input in the next step. Also note that the tasks are being run approximately every 2 minutes. As was described in Lab13 on AIM level LOW and MEDIUM, AIM tasks will continue to be scheduled during each IMCO cycle when under memory pressure. Again, this means that it may take a couple of cycles before an object is populated by AIM in the IM column store.
Make note of the last task_id. We will use this as input in the next step. Also note that the tasks are being run approximately every 2 minutes. AIM tasks will be scheduled during each IMCO cycle, which is approximately every 2 minutes, when the IM column store is under memory pressure. This means that it may take a couple of cycles before an object is populated by AIM in the IM column store.

13. Now let's look at the AIM task details, or what actually happened.

Expand Down Expand Up @@ -998,7 +998,7 @@ SQL>
SQL>
```

As a reminder, take a look at the OBJECT_NAME and the ACTION. Now that the IM column store is under memory pressure AIM has taken over control of population and there is a lot going on. Based on usage statistics AIM will populate the objects that will result in the most benefit to queries being run. You may want to take a look at some of the other task details to get a better picture of what has happened. Also note that now that AIM is controlling population the PRIORITY level will be ignored and AIM will decide which objects to populate and which to evict.
Take a look at the OBJECT_NAME and the ACTION. Now that the IM column store is under memory pressure AIM has taken over control of population and there is a lot going on. Based on usage statistics AIM will populate the objects that will result in the most benefit to queries being run. You may want to take a look at some of the other task details to get a better picture of what has happened. Also note that now that AIM is controlling population the PRIORITY level will be ignored and AIM will decide which objects to populate and which to evict.

14. Now let's turn AIM off and see what happens.

Expand Down Expand Up @@ -1141,7 +1141,7 @@ SQL>
SQL>
```

Notice that all of the objects that were enabled for inmemory when the AIM level was set to high have now been disabled. However, the LINEORDER partitions that we manually enabled are still enabled.
Notice that all of the objects that were enabled for inmemory when the AIM level was set to HIGH have now been disabled. However, the LINEORDER partitions that we manually enabled are still enabled.

16. What has happened to the populated segments in the IM column store?

Expand Down Expand Up @@ -1284,7 +1284,7 @@ SQL>

## Conclusion

This lab demonstrated how then new INMEMORY\_AUTOMATIC\_LEVEL = HIGH feature works and how AIM level high can enable the automatic management of the contents of IM column store. This means no more having to try and figure out which objects would get the most benefit from being populated. Now the database will do it for you.
This lab demonstrated how the new INMEMORY\_AUTOMATIC\_LEVEL = HIGH feature works and how AIM level high can enable the automatic management of the contents of IM column store. This means no more having to try and figure out which objects would get the most benefit from being populated. Now the database will do it for you.

You may now **proceed to the next lab**.

Expand Down
30 changes: 30 additions & 0 deletions in-memory-21c/aim-high/files/01_aim_attributes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@../aim_login.sql

set pages 999
set lines 200
set tab off

column owner format a10;
column table_name format a20;
column partition_name format a15;
column inmemory format a10;
column INMEMORY_PRIORITY heading 'INMEMORY|PRIORITY' format a10;
column INMEMORY_DISTRIBUTE heading 'INMEMORY|DISTRIBUTE' format a12;
column INMEMORY_COMPRESSION heading 'INMEMORY|COMPRESSION' format a14;
set echo on

-- Show table attributes

select owner, table_name, NULL as partition_name, inmemory,
inmemory_priority, inmemory_distribute, inmemory_compression
from dba_tables
where owner in ('AIM','SSB')
UNION ALL
select table_owner as owner, table_name, partition_name, inmemory,
inmemory_priority, inmemory_distribute, inmemory_compression
from dba_tab_partitions
where table_owner in ('AIM','SSB')
order by owner, table_name, partition_name;

set echo off

36 changes: 36 additions & 0 deletions in-memory-21c/aim-high/files/02_disable_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@../aim_login.sql

set pages 9999
set lines 150

set serveroutput on;
declare
v_ddl varchar2(1000);
begin
for tab_cursor in (
select owner, table_name
from dba_tables
where owner not in ('AUDSYS','SYS')
and inmemory = 'ENABLED'
)
loop
v_ddl := 'alter table '||tab_cursor.owner||'.'||tab_cursor.table_name||' no inmemory';
dbms_output.put_line(v_ddl);
execute immediate v_ddl;
end loop;
--
for part_cursor in (
select table_owner, table_name, partition_name
from dba_tab_partitions
where table_owner not in ('AUDSYS','SYS')
and inmemory = 'ENABLED'
)
loop
v_ddl := 'alter table '||part_cursor.table_owner||'.'||part_cursor.table_name||
' modify partition '||part_cursor.partition_name||' no inmemory';
dbms_output.put_line(v_ddl);
execute immediate v_ddl;
end loop;
end;
/

12 changes: 12 additions & 0 deletions in-memory-21c/aim-high/files/03_pop_ssb_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@../aim_login.sql

set pages 999
set lines 200
set echo on

alter table ssb.lineorder inmemory;

exec dbms_inmemory.populate('SSB','LINEORDER');

set echo off

28 changes: 28 additions & 0 deletions in-memory-21c/aim-high/files/04_im_populated.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@../aim_login.sql

set pages 9999
set lines 150
set tab off

column owner format a10;
column segment_name format a20;
column partition_name format a15;
column populate_status format a15;
column bytes heading 'Disk Size' format 999,999,999,999
column inmemory_size heading 'In-Memory|Size' format 999,999,999,999
column bytes_not_populated heading 'Bytes|Not Populated' format 999,999,999,999
set echo on

-- Query the view v$IM_SEGMENTS to shows what objects are in the column store
-- and how much of the objects were populated. When the BYTES_NOT_POPULATED is 0
-- it indicates the entire table was populated.

select owner, segment_name, partition_name, populate_status, bytes,
inmemory_size, bytes_not_populated
from v$im_segments
where owner not in ('AUDSYS','SYS')
order by owner, segment_name, partition_name;

select * from v$inmemory_area;

set echo off
30 changes: 30 additions & 0 deletions in-memory-21c/aim-high/files/05_aim_attributes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@../aim_login.sql

set pages 999
set lines 200
set tab off

column owner format a10;
column table_name format a20;
column partition_name format a15;
column inmemory format a10;
column INMEMORY_PRIORITY heading 'INMEMORY|PRIORITY' format a10;
column INMEMORY_DISTRIBUTE heading 'INMEMORY|DISTRIBUTE' format a12;
column INMEMORY_COMPRESSION heading 'INMEMORY|COMPRESSION' format a14;
set echo on

-- Show table attributes

select owner, table_name, NULL as partition_name, inmemory,
inmemory_priority, inmemory_distribute, inmemory_compression
from dba_tables
where owner in ('AIM','SSB')
UNION ALL
select table_owner as owner, table_name, partition_name, inmemory,
inmemory_priority, inmemory_distribute, inmemory_compression
from dba_tab_partitions
where table_owner in ('AIM','SSB')
order by owner, table_name, partition_name;

set echo off

12 changes: 12 additions & 0 deletions in-memory-21c/aim-high/files/06_aim_high.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@../aim_login.sql

set pages 9999
set lines 150

show parameters inmemory_automatic_level

alter system set inmemory_automatic_level=high;

show parameters inmemory_automatic_level


30 changes: 30 additions & 0 deletions in-memory-21c/aim-high/files/07_aim_attributes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@../aim_login.sql

set pages 999
set lines 200
set tab off

column owner format a10;
column table_name format a20;
column partition_name format a15;
column inmemory format a10;
column INMEMORY_PRIORITY heading 'INMEMORY|PRIORITY' format a10;
column INMEMORY_DISTRIBUTE heading 'INMEMORY|DISTRIBUTE' format a12;
column INMEMORY_COMPRESSION heading 'INMEMORY|COMPRESSION' format a14;
set echo on

-- Show table attributes

select owner, table_name, NULL as partition_name, inmemory,
inmemory_priority, inmemory_distribute, inmemory_compression
from dba_tables
where owner in ('AIM','SSB')
UNION ALL
select table_owner as owner, table_name, partition_name, inmemory,
inmemory_priority, inmemory_distribute, inmemory_compression
from dba_tab_partitions
where table_owner in ('AIM','SSB')
order by owner, table_name, partition_name;

set echo off

28 changes: 28 additions & 0 deletions in-memory-21c/aim-high/files/08_im_populated.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@../aim_login.sql

set pages 9999
set lines 150
set tab off

column owner format a10;
column segment_name format a20;
column partition_name format a15;
column populate_status format a15;
column bytes heading 'Disk Size' format 999,999,999,999
column inmemory_size heading 'In-Memory|Size' format 999,999,999,999
column bytes_not_populated heading 'Bytes|Not Populated' format 999,999,999,999
set echo on

-- Query the view v$IM_SEGMENTS to shows what objects are in the column store
-- and how much of the objects were populated. When the BYTES_NOT_POPULATED is 0
-- it indicates the entire table was populated.

select owner, segment_name, partition_name, populate_status, bytes,
inmemory_size, bytes_not_populated
from v$im_segments
where owner not in ('AUDSYS','SYS')
order by owner, segment_name, partition_name;

select * from v$inmemory_area;

set echo off
26 changes: 26 additions & 0 deletions in-memory-21c/aim-high/files/09_pop_aim_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@../aim_login.sql

set pages 999
set lines 200
set echo on

select count(*) from lrgtab1;
select count(*) from lrgtab1;

select count(*) from lrgtab2;
select count(*) from lrgtab2;
select count(*) from lrgtab2;

select count(*) from lrgtab3;
select count(*) from medtab1;
select count(*) from medtab1;
select count(*) from medtab1;
select count(*) from medtab2;
select count(*) from medtab2;
select count(*) from medtab2;

select count(*) from lrgtab4;
select count(*) from lrgtab4;

set echo off

28 changes: 28 additions & 0 deletions in-memory-21c/aim-high/files/10_im_populated.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@../aim_login.sql

set pages 9999
set lines 150
set tab off

column owner format a10;
column segment_name format a20;
column partition_name format a15;
column populate_status format a15;
column bytes heading 'Disk Size' format 999,999,999,999
column inmemory_size heading 'In-Memory|Size' format 999,999,999,999
column bytes_not_populated heading 'Bytes|Not Populated' format 999,999,999,999
set echo on

-- Query the view v$IM_SEGMENTS to shows what objects are in the column store
-- and how much of the objects were populated. When the BYTES_NOT_POPULATED is 0
-- it indicates the entire table was populated.

select owner, segment_name, partition_name, populate_status, bytes,
inmemory_size, bytes_not_populated
from v$im_segments
where owner not in ('AUDSYS','SYS')
order by owner, segment_name, partition_name;

select * from v$inmemory_area;

set echo off
47 changes: 47 additions & 0 deletions in-memory-21c/aim-high/files/11_hm_stats.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@../aim_login.sql

set pages 9999
set lines 150
set echo off
set tab off

-- Heat Map query
-- (Flush Heat Map data: exec dbms_ilm.flush_all_segments)
--

col owner format a10;
col object_name format a20;
col subobject_name format a15;
col track_time format a16;
col segment_write heading 'SEG|WRITE' format a10;
col segment_read heading 'SEG|READ' format a10;
col full_scan heading 'FULL|SCAN' format a10;
col lookup_scan heading 'LOOKUP|SCAN' format a10;
col n_fts heading 'NUM FULL|SCAN' format 99999999;
col n_lookup heading 'NUM LOOKUP|SCAN' format 99999999;
col n_write heading 'NUM SEG|WRITE' format 99999999;
--
select
OWNER,
OBJECT_NAME,
SUBOBJECT_NAME,
to_char(TRACK_TIME,'MM/DD/YYYY HH24:MI') track_time,
SEGMENT_WRITE,
SEGMENT_READ,
FULL_SCAN,
LOOKUP_SCAN,
N_FTS,
N_LOOKUP,
N_WRITE
from
sys."_SYS_HEAT_MAP_SEG_HISTOGRAM" h,
dba_objects o
where
o.object_id = h.obj#
and track_time >= sysdate-1
order by
track_time,
OWNER,
OBJECT_NAME,
SUBOBJECT_NAME;

Loading