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等数据的,因此在运行前可以先跑一个测试负载。

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
上一篇:sqlalchemy.exc.IntegrityError: (mysql.connector.errors.IntegrityError) 1062 (23000): Duplicate entry


下一篇:python shutil模块