性能测试
- 显示数据库当前的连接数:
select count(*) from v$process;
- 显示数据库最大连接数:
select value from v$parameter where name ='processes';
- 修改最大Oracle最大连接数:
alter systemset processes = 300 scope = spfile;
- 显示当前的session连接数:
select count(*) from v$session
- 查看当前有哪些用户正在使用数据:
SELECT osuser,a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine from v$session a, v$sqlarea b where a.sql_address =b.address order by cpu_time/executionsdesc;
- 查看数据库中SGA:
System globalarea (SGA),system global area(PGA);
- 查看连接oracle的所有机器的连接数:
select machine,count(*) fromv$session groupbymachine;
- 查看连接oracle的所有机器的连接数和状态:
select machine,status,count(*) fromv$session groupbymachine,status orderbystatus;
- Oracle 11g设置内存自动管理:
ALTER SYSTEM SETMEMORY_TARGET= 1024M SCOPE=SPFILE;
ALTER SYSTEM SETmemory_max_target= 1500M SCOPE=SPFILE;
ALTER SYSTEM SETSGA_TARGET= 0 SCOPE=SPFILE;
ALTER SYSTEM SETSGA_MAX_SIZE=800MSCOPE=SPFILE;
ALTER SYSTEM SETPGA_AGGREGATE_TARGET= 0 SCOPE=SPFILE;
alter system setpre_page_sga=FALSEscope=spfile;
- 查看消耗磁盘读取最多的SQL Top 5:
select disk_reads,sql_text,SQL_FULLTEXT
from (selectsql_text,disk_reads,SQL_FULLTEXT,
dense_rank() over
(order by disk_reads desc) disk_reads_rank
from v$sql)
wheredisk_reads_rank <=5;
实例:
通过linux中消耗资源高的进程号获取oracle消耗资源的sql语句。
1、linux中使用top命名查看oracle进程中消耗资源最高的进程号;
2、oracle中使用命令:
select c.spid,a.p1,a.p1raw,a.p2,a.event,b.sql_text,b.SQL_FULLTEXT,b.SQL_ID
from v$session a,v$sql b,v$process c
where a.wait_class<>'Idle' and a.sql_id=b.sql_id and a.PADDR=c.addr
order by event;
3、查询结果显示出各个sql语句对应的进程号,从中找出top命令中对应消耗资源高的进程号即可找到相应的sql语句。