日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle内存表与临时表,Oracle 临时表之临时表空间组(TTG)

發布時間:2025/3/12 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle内存表与临时表,Oracle 临时表之临时表空间组(TTG) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境:

sys@ORCL> select * from v$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE? ? 10.2.0.1.0? ? ? Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

在Oracle中,temp猶如win下的虛擬內存和unix下的swap分區

TTG是10g引入的概念,目的就是為了減少IO競爭

只有臨時表空間可以定組,普通的表空間無法定組

對待TTG就像對待單個臨時表空間一樣,無甚區別

TTG本身不能被創建,它隨著temp的加入而創建,temp的脫離而刪除

alter tablespace temp tablespace group '';

我們知道一個用戶只能使用一個臨時表空間,而一個臨時表空間中只存在一個臨時段

當一個session在使用臨時段時,其他session再請求臨時段時需要等到擁有該臨時段的session使用完畢之后才能使用

而臨時表空間組的出現大大改善了同一用戶并發session對臨時段的爭奪

因為臨時表空間組的出現使用戶能夠使用多個臨時表空間了

下面作個簡單測試

sys@ORCL> create temporary tablespace temp1 tempfile size 20M tablespace group tempg;

Tablespace created.

sys@ORCL> create temporary tablespace temp2 tempfile size 20M tablespace group tempg;

Tablespace created.

sys@ORCL> create temporary tablespace temp3 tempfile size 20M tablespace group tempg;

Tablespace created.

sys@ORCL> alter database default temporary tablespace tempg;

Database altered.

sys@ORCL> drop tablespace temp;

Tablespace dropped.

sys@ORCL> select * from dba_tablespace_groups;

GROUP_NAME? ? ? ? ? ? ? ? ? ? TABLESPACE_NAME

------------------------------ ------------------------------

TEMPG? ? ? ? ? ? ? ? ? ? ? ? ? TEMP1

TEMPG? ? ? ? ? ? ? ? ? ? ? ? ? TEMP2

TEMPG? ? ? ? ? ? ? ? ? ? ? ? ? TEMP3

sys@ORCL> alter user hr temporary tablespace tempg;

User altered.

sys@ORCL> conn hr/hr

Connected.

hr@ORCL> create table t as select * from dba_objects;

Table created.

hr@ORCL> begin

2? ? ? ? for i in 1..4

3? ? ? ? loop

4? ? ? ? ? insert into t select * from t;

5? ? ? ? end loop;

6? ? ? ? commit;

7? ? ? end;

8? /

PL/SQL procedure successfully completed.

hr@ORCL> create table tt as select * from t;

Table created.

分別打開兩個session以用戶hr登錄對表t和tt同時進行排序,之后通過如下查詢監視對臨時表空間的使用情況

sys@ORCL> select operation_type ,sql_id , tablespace,tempseg_size,number_passes from v$sql_workarea_active;

OPERATION_ SQL_ID? ? ? ? TABLESPACE? ? ? ? ? ? ? ? ? ? TEMPSEG_SIZE NUMBER_PASSES

---------- ------------- ------------------------------ ------------ -------------

SORT (v2)? b7q3tuybvatbt? ? temp1? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0

SORT (v2)? cn7ucn092pg8s? ? temp3? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0

sys@ORCL> select sql_text from v$sql where sql_id in (select sql_id from v$sql_workarea_active);

SQL_TEXT

---------------------------------------------

select object_id from t order by object_id desc

select object_id from tt order by object_id desc

發現來自同一用戶hr的不同session同時排序時使用了同一臨時表空間組內的不同臨時表空間

這樣大大減少了之前同一用戶只能使用一個臨時表空間而產生的請求臨時段的等待時間

總結

以上是生活随笔為你收集整理的oracle内存表与临时表,Oracle 临时表之临时表空间组(TTG)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。