Oracle Database In-Memory Advisor

概述

本文是此白皮书的阅读笔记。

Database In-Memory 以下简称 DBIM。
DBIM Advisor以下简称建议器。

DBIM是12.1.0.2时发布的,也就是说在12c刚发布时并无此特性。DBIM的发布起码有一部分是针对SAP HANA的。
建议器的作用:

  1. 评估DBIM是否对分析带来好处
  2. 对于OLTP负载,是否可以删除索引
  3. 评估所需的内存量
  4. 生成为对象配置DBIM的脚本

安装

使用SYS用户。
建议器可安装到CDB或PDB,本例为后者。
新建一临时目录,然后解压:

unzip imadvisor.zip

开始安装,时间需要几分钟。唯一需要输入的是系统表空间 SYSTEM和临时表空间TEMP:

$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Aug 24 11:26:34 2019

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> @instimadv
Welcome to the Oracle Database In-Memory Advisor (DBMS_INMEMORY_ADVISOR)
installation.


DBMS_INMEMORY_ADVISOR uses Active Session History (ASH), Automatic Workload
Repository (AWR) and optionally SQL Tuning Sets (STS) to determine which
tables, partitions and subpartitions to place In Memory for optimized analytics
processing performance.  DBMS_INMEMORY_ADVISOR produces a recommendation report
and a SQLPlus script to implement its recommendations.

DBMS_INMEMORY_ADVISOR users require the ADVISOR privilege.



This installation script will create user C##IMADVISOR and add object
definitions to the schema.  This user is created using the IDENTIFIED BY
password method with a random-generated password.  If you prefer to use either
the IDENTIFIED EXTERNALLY or IDENTIFIED GLOBALLY method, abort this installation
by pressing ^C.  Then create user C##IMADVISOR using your preferred
method.  Add no objects or grants to the C##IMADVISOR schema.  Then run
this installation script again.

User C##IMADVISOR requires both a permanent and temporary tablespace.
Available tablespaces:


TABLESPACE_NAME
------------------------------
SYSAUX
SYSTEM (default permanent tablespace)
TEMP (default temporary tablespace)
UNDOTBS1
USERS


Enter value for permanent_tablespace: SYSTEM

Permanent tablespace to be used with C##IMADVISOR: SYSTEM


Enter value for temporary_tablespace: TEMP

Temporary tablespace to be used with C##IMADVISOR: TEMP

No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.
No errors.

All done!

DBMS_INMEMORY_ADVISOR installation successful.

Users who will use the DBMS_INMEMORY_ADVISOR package must be granted
the ADVISOR privilege.


DBMS_INMEMORY_ADVISOR installation and setup complete.

To uninstall:

SQL> @catnoimadv.sql

Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

运行

建议器是基于AWR等数据的,因此在运行前可以先跑一个测试负载。

$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Aug 24 11:31:23 2019

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> @imadvisor_recommendations


This script creates and runs an In-Memory Advisor task that analyzes
your workload to determine an optimal In-Memory configuration.

This script then generates an HTML recommendation report file in the
current working  directory: imadvisor_.html

This script also generates a sqlplus DDL script to implement the
recommendations: imadvisor_.sql

NOTE: You may specify one of your existing tasks if you wish to optimize for a
different In-Memory size.

Using an existing, executed task is faster than a new task since a new task
requires statistics gathering and analysis.

But if you wish to analyze a different workload or use a different statistics
capture window or add a SQLSET, you must specify a new task.

The following is a list of your existing tasks:


TASK_NAME                      DATE_CREATED
------------------------------ -----------------------------
im_advisor_task_20190824113137 2019-AUG-24 11:32:42
im_advisor_task_20190824130450 2019-AUG-24 13:06:18
im_advisor_task_20190824131244 2019-AUG-24 13:13:03



Default task_name (new task): im_advisor_task_20190824131613
Enter value for task_name:

Advisor task name specified: im_advisor_task_20190824131613 (default)

New Advisor task will be named: im_advisor_task_20190824131613...


Analyzing and reporting on a live workload on this database (DBID=2785980613)...
Enter value for pdb_name: orclpdb1

orclpdb1

The In-Memory Advisor optimizes the In-Memory configuration for a specific
In-Memory size that you choose.

After analysis, the In-Memory Advisor can provide you a list of performance
benefit estimates for a range of In-Memory sizes.  You may then choose the
In-Memory size for which you wish to optimize.

If you already know the specific In-Memory size you wish, please enter
the value now.  Format: nnnnnnn[KB|MB|GB|TB]

Or press  to get performance estimates first.
Enter value for inmemory_size:

The In-Memory Advisor will display performance benefit estimates after analysis.


Enter begin time for report:

--    Valid input formats:
--      To specify absolute begin time:
--        [MM/DD[/YY]] HH24:MI[:SS]
--        Examples: 02/23/03 14:30:15
--                  02/23 14:30:15
--                  14:30:15
--                  14:30
--      To specify relative begin time: (start with '-' sign)
--        -[HH24:]MI
--        Examples: -1:15  (SYSDATE - 1 Hr 15 Mins)
--                  -25    (SYSDATE - 25 Mins)

Default begin time: -60
Enter value for begin_time:

Report begin time specified:


Enter duration in minutes starting from begin time:
(defaults to SYSDATE - begin_time)

Enter value for duration:

Report duration specified:

Using 2019-AUG-24 12:16:22.000000000 as report begin time
Using 2019-AUG-24 13:16:24.000000000 as report end time


You may optionally specify a comma separated list of object owner
and name patterns to be considered for In Memory Placement.
Example:

GEEK_SUMMARY.%,%.GEEK_%

Press ENTER to consider all objects.


Enter value for consider_objects_like: D18.%

Considering only objects matching these patterns for In Memory placement:

D18.%

In-Memory Advisor: Adding statistics...

In-Memory Advisor: Finished adding statistics.

In-Memory Advisor: Analyzing statistics...

In-Memory Advisor: Finished analyzing statistics.



The Advisor estimates the following performance benefits:


________________________________________________________________________
|                                                                      |
|                                    ESTIMATED      ESTIMATED          |
|                                    ANALYTICS      ANALYTICS          |
|                                    PROCESSING    PROCESSING          |
|                    PERCENTAGE         TIME       PERFORMANCE         |
|         IN-MEMORY  OF MAXIMUM      REDUCTION     IMPROVEMENT         |
|           SIZE      SGA SIZE       (SECONDS)*      FACTOR*           |
|         ---------  ----------  ----------------  -----------         |
|           99.97MB       31           189           5.6X              |
|           94.98MB       29                                           |
|           89.98MB       28                                           |
|           84.98MB       26                                           |
|           79.98MB       25                                           |
|           74.98MB       23                                           |
|           69.98MB       22                                           |
|           64.98MB       20                                           |
|           59.98MB       19                                           |
|           54.99MB       17                                           |
|           49.99MB       15                                           |
|           44.99MB       14                                           |
|           39.99MB       12                                           |
|           34.99MB       11                                           |
|           29.99MB       9                                            |
|           24.99MB       8                                            |
|           19.99MB       6                                            |
|           15.00MB       5                                            |
|           9.997MB       3                                            |
|           4.999MB       2                                            |
|                                                                      |
| *Estimates: The In-Memory Advisor's estimates are useful for making  |
|  In-Memory decisions.  But they are not precise.  Due to performance |
|  variations caused by workload diversity, the Advisor's performance  |
|  estimates are conservatively limited to no more than 10.0X          |
|  faster.                                                             |
|                                                                      |
|______________________________________________________________________|



Choose the In-Memory size you wish for optimization (default=99.97MB):


The Advisor is optimizing for an In-Memory size of 99.97MB...
Fetching recommendation files for task: im_advisor_task_20190824131613
Placing recommendation files in: the current working directory

Fetched file: imadvisor_im_advisor_task_20190824131613.html
Purpose:      recommendation report primary html page

Fetched file: imadvisor_im_advisor_task_20190824131613.sql
Purpose:      recommendation DDL sqlplus script

You can re-run this task with this script and specify a different an In-Memory
size.  Re-running a task to optimize for a different In-Memory size is faster
than creatng and running a new task from scratch.

自动生成的SQL脚本如下:

[oracle@oracle-12201-vagrant ~]$ cat imadvisor_im_advisor_task_20190824131613.sql
Rem Copyright (c) 2014, 2016, Oracle and/or its affiliates.  All rights reserved.
ALTER TABLE "D18"."TAB01" INMEMORY NO MEMCOMPRESS;

另一次运行:

Choose the In-Memory size you wish for optimization (default=23.11MB):
200MB

The Advisor is optimizing for an In-Memory size of 200MB...
Fetching recommendation files for task: im_advisor_task_20190825110517
Placing recommendation files in: the current working directory

Fetched file: imadvisor_im_advisor_task_20190825110517.html
Purpose:      recommendation report primary html page

Fetched file: imadvisor_im_advisor_task_20190825110517.sql
Purpose:      recommendation DDL sqlplus script

You can re-run this task with this script and specify a different an In-Memory
size.  Re-running a task to optimize for a different In-Memory size is faster
than creatng and running a new task from scratch.


SQL建议:

Rem Copyright (c) 2014, 2016, Oracle and/or its affiliates.  All rights reserved.
ALTER TABLE "D18"."表名" INMEMORY MEMCOMPRESS FOR QUERY LOW;

参考

  1. Oracle Database In-Memory Advisor (文档 ID 1965343.1)
  2. https://www.oracle.com/technetwork/database/manageability/inmemory-advisor-2412222.html
  3. http://www.oracle.com/technetwork/database/in-memory/overview/twp-oracle-database-in-memory-2245633.html

你可能感兴趣的:(内存数据库,In-Memory,Computing,Technology)