本文共 2238 字,大约阅读时间需要 7 分钟。
转载自https://blog.51cto.com/13693838/2104229
纯是为了记录...--性能优化时用的。--查看为数据库分配的内存。
select * from v$sga;
select * from v$sgastat;
--xshell 中, 查看为数据库分配多少cpu 。
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ sqlplus zy_12c/1@192.168.100.51:1521/orcl
SQL> show parameters cpu
--1、查看ORACLE最大游标数
SQL> show parameter open_cursors;
--2、查看当前打开的游标数目
SQL> select count(*) from v$open_cursor;
--3、修改ORACLE最大游标数
SQL> alter system set open_cursors=1000 scope=both;
--系统已更改。
SQL> show parameter open_cursors;
--数据库性能瓶颈分析。
select * from v$parameter a where a.NAME in('shared_pool_size','log_buffer','db_cache_size','java_pool_size','larger_pool_size'); --SGA分配情况。
select component,current_size/1048576,min_size/1048576 from v$sga_dynamic_components; --查看SGA使用情况
SQL> show parameter pga ; ---查询PGA总大小。
SQL> select round(sum(pga_alloc_mem)/1048576,1) from v$process; --已经消耗的PGA
--每个session都会占用一定的PGA资源,必要的时候,需要控制session的数量。
select count(*) from v$session;
--查询数据库表空间使用情况。
SELECT a.tablespace_name,
a.bytes total,
b.bytes used,
c.bytes free,
(b.bytes * 100) / a.bytes "% USED ",
(c.bytes * 100) / a.bytes "% FREE "
FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
WHERE a.tablespace_name = b.tablespace_name
AND a.tablespace_name = c.tablespace_name;
--查询用户权限
select * from session_privs;
--查询使用过的表空间
select distinct tablespace_name from dba_all_tables;--系统表
select distinct tablespace_name from user_all_tables; --用户表
--根据表空间查询,表空间内的表。
select table_name from dba_all_tables where tablespace_name = tablespacename
--查询数据库进程数
sql>select parameter process;
sql>select count(*) from v$process;
--目前可以调整的主要是数据库内存配置和最大连接数的基本配置,提高并发处理效率。
--在进行测试时监测会话及连接等信息
Select * from v$session;
Select * from v$session where status='ACTIVE';
Select * from v$process;
Select * from v$locked_object;
--建议调整
--SGA参数Data buffer,将其尽可能的调大些。避免重复查询的磁盘I/O操作。
--调整PGA参数设置原则:
--SGA+PGA+OS使用内存<总物理RAM。在调试过程中可以观察PGA缓存设置命中率:
select value from v$sysstat where name ='physical reads';
select value from v$sysstat where name ='physical reads direct';
select value from v$sysstat where name ='physical reads direct (lob)';
select value from v$sysstat where name ='consistent gets';
select value from v$sysstat where name = 'db block gets';
转载于:https://blog.51cto.com/8352164/2370239