1.ASH占用的内存大小 ASH的采集信息保存在内存中,在旧的信息被采样到AWR中后,可被新采集的信息覆盖,重启oracle后该信息被清除。分配给ASH的内存大小可以查询到: SQL select pool, name, bytes/1024/1024 From v$sgastat where name like ‘%ASH %’; POO
1.ASH占用的内存大小
ASH的采集信息保存在内存中,在旧的信息被采样到AWR中后,可被新采集的信息覆盖,重启oracle后该信息被清除。分配给ASH的内存大小可以查询到:
SQL> select pool, name, bytes/1024/1024 From v$sgastat where name like ‘%ASH %’;
POOL NAME BYTES/1024/1024
———— ————————– —————
shared pool ASH buffers 4
2.mmon进程与mmnl进程
2.1)快照由一个称为 MMON 的新的后台进程(及其从进程)以及MMNL后台进程自动地每隔固定时间采样一次。我们先来看一下10g的概念指南中对这两个新增加的后台进程的介绍:
MMON进程负责执行多种和管理相关(manageability-related)的后台任务
例如:当某个测量值(metrics)超过了预设的限定值(threshold value)后提交警告,创建新的 MMON 隶属进程(MMON slave process)来进行快照(snapshot),捕获最近修改过的 SQL 对象的统计信息
2.2)MMNL进程负责执行轻量级的且频率较高的和可管理性相关的后台任务
例如:捕获会话历史信息,测量值计算等。
2.3)AWR的采样工作默认是由MMON进程每个1小时执行一次,ASH信息同样会被采样写出到AWR负载库中。虽然ASH buffer被设计为保留1小时的信息,但很多时候这个内存是不够的,当ASH buffer写满后,另外一个后台进程MMNL将会主动将ASH信息写出。
3.SYSAUX表空间
AWR 使用几个表来存储采集的统计数据,所有的表都存储在新的名称为 SYSAUX 的特定表空间中的 SYS 模式下,并且以 WRM$_* 和 WRH$_* 的格式命名。前一种类型存储元数据信息(如检查的数据库和采集的快照),后一种类型保存实际采集的统计数据。H 代表“历史数据 (historical)”而 M 代表“元数据 (metadata)”
使用sql语句: select table_name from dba_tables where table_name like ‘WRM$%’ or table_name like ‘WRH$%’;查询
当SYSAUX表空间满后,AWR将自动覆盖掉旧的信息,并在警告日志中记录一条相关信息:
ORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_3533490838_1522 by 128 in tablespace SYSAUX
4.采样频率和保留时间
可以通过查询视图dba_hist_wr_control或(wrm$_wr_control)来查询AWR的采样频率和保留时间。默认为每1小时采样一次,采样信息保留时间为(7/10g|8/11g)天。
SQL> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL
———- ——————– ——————– ———-
3393548168 +00000 00:30:00.0 +00010 00:00:00.0 DEFAULT
或者
SQL> select DBID, SNAP_INTERVAL, SNAPINT_NUM, RETENTION from wrm$_wr_control;
DBID SNAP_INTERVAL SNAPINT_NUM RETENTION
———- ——————– ———– ——————–
3393548168 +00000 00:30:00.0 1800 +00010 00:00:00.0
修改采集频率和保存时间: exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>5*24*60);
Note:输入的retention参数值不能被目前库中保存的数据的范围小(如果要减少保存时间,需要先删除历史数据)
5.采样数据量
由于数据量巨大,把所有ASH数据写到磁盘上是不可接受的。一般是在写到磁盘的时候过滤这个数据,写出的数据占采样数据的10%,写出时通过direct-path insert完成,尽量减少日志生成,从而最小化数据库性能的影响。
6.初始化参数statistics_level
AWR的行为受到参数STATISTICS_LEVEL的影响。这个参数有三个值:
BASIC:awr统计的计算和衍生值关闭.只收集少量的数据库统计信息.
TYPICAL:默认值.只有部分的统计收集.他们代表需要的典型监控oracle数据库的行为.
ALL : 所有可能的统计都被捕捉. 并且有操作系统的一些信息.这个级别的捕捉应该在很少的情况下,比如你要更多的sql诊断信息的时候才使用.
7.快照管理
7.1)执行
exec dbms_workload_repository.create_snapshot();
7.2)查询
select * from wrh$_active_session_history
7.3)删除
exec dbms_workload_repository.drop_snapshot_range(low_snap_id => 90, high_snap_id => 96, dbid => 1160732652);
8. 基线管理
8.1)创建baseline,保存这些数据用于将来分析和比较
exec dbms_workload_repository.create_baseline(start_snap_id => 1003, end_snap_id => 1013, ‘apply_interest_1′);
8.2)删除baseline
exec DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(baseline_name => ‘apply_interest_1′, cascade => FALSE);

MySQL processes data replication through three modes: asynchronous, semi-synchronous and group replication. 1) Asynchronous replication performance is high but data may be lost. 2) Semi-synchronous replication improves data security but increases latency. 3) Group replication supports multi-master replication and failover, suitable for high availability requirements.

The EXPLAIN statement can be used to analyze and improve SQL query performance. 1. Execute the EXPLAIN statement to view the query plan. 2. Analyze the output results, pay attention to access type, index usage and JOIN order. 3. Create or adjust indexes based on the analysis results, optimize JOIN operations, and avoid full table scanning to improve query efficiency.

Using mysqldump for logical backup and MySQLEnterpriseBackup for hot backup are effective ways to back up MySQL databases. 1. Use mysqldump to back up the database: mysqldump-uroot-pmydatabase>mydatabase_backup.sql. 2. Use MySQLEnterpriseBackup for hot backup: mysqlbackup--user=root-password=password--backup-dir=/path/to/backupbackup. When recovering, use the corresponding life

The main reasons for slow MySQL query include missing or improper use of indexes, query complexity, excessive data volume and insufficient hardware resources. Optimization suggestions include: 1. Create appropriate indexes; 2. Optimize query statements; 3. Use table partitioning technology; 4. Appropriately upgrade hardware.

MySQL view is a virtual table based on SQL query results and does not store data. 1) Views simplify complex queries, 2) Enhance data security, and 3) Maintain data consistency. Views are stored queries in databases that can be used like tables, but data is generated dynamically.

MySQLdiffersfromotherSQLdialectsinsyntaxforLIMIT,auto-increment,stringcomparison,subqueries,andperformanceanalysis.1)MySQLusesLIMIT,whileSQLServerusesTOPandOracleusesROWNUM.2)MySQL'sAUTO_INCREMENTcontrastswithPostgreSQL'sSERIALandOracle'ssequenceandt

MySQL partitioning improves performance and simplifies maintenance. 1) Divide large tables into small pieces by specific criteria (such as date ranges), 2) physically divide data into independent files, 3) MySQL can focus on related partitions when querying, 4) Query optimizer can skip unrelated partitions, 5) Choosing the right partition strategy and maintaining it regularly is key.

How to grant and revoke permissions in MySQL? 1. Use the GRANT statement to grant permissions, such as GRANTALLPRIVILEGESONdatabase_name.TO'username'@'host'; 2. Use the REVOKE statement to revoke permissions, such as REVOKEALLPRIVILEGESONdatabase_name.FROM'username'@'host' to ensure timely communication of permission changes.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
