使用不同的临时表空间为不同用户进行配置来减少i/o争用
那如何为同一个用户分配不同的临时表空间来实现会话级的减少i/o争用。
这种需求在高并发的开发环境下还是很多的
在oracle的10g 11g及之后的版本可以通过配置临时表空间组,为同一用户的不同会话分配不同临时表空间。
此处以scott用户为例
1)查询是否存在表空间组
select * from dba_tablespace_groups;
2)创建临时表空间组
create temporary tablespace temp1 tempfile '/oradata/orcl/temp011.dbf' size 100m tablespace group tmp_grp1;
create temporary tablespace temp2 tempfile '/oradata/orcl/temp012.dbf' size 100m tablespace group tmp_grp1;
create temporary tablespace temp3 tempfile '/oradata/orcl/temp013.dbf' size 100m tablespace group tmp_grp1;
3)将某个表空间移动到组内(如果之前有创建的可以加入到组中)
alter tablespace temp4 tablespace group tmp_grp1;
4)修改某用户的临时表空间 (这里指定的是组)
alter user scott temporary tablespace tmp_grp1;
5)查看用户默认表空间
select temporary_tablespace from dba_users where username='SCOTT';
6)使用scott用户创建多个会话,测试7的结果
select a.table_name,b.table_name from all_tables a,all_tables b order by a.table_name;
7)查询临时表空间
select username,session_num,tablespace from v$sort_usage where username='SCOTT';
8)删除临时表空间,回收空间,当全部删完后,组消失了。
drop tablespace temp3 including contents and datafiles;