You are on page 1of 5

Data Tablespace Management

1. The tablespace alert is configured in Sitescope or UNIX crontab (oracle user) for databases.
Below is the sample email subject from Sitescope for tablespace alert.
Warning: TableSpace PHASTAGE1 Monitor >=90% Status: content match error, 0.296 sec, 1
row, tablespace_name -> MAC_DAT, Free MB -> 3233, Used Pct -> 90 (10.62.2...
Below is the sample email subject from crontab for tablespace alert.
catlmsxp137 22:20:18 - PHASTAGE dba0911_spaceprobs.sh
2. Fetch the file, mount, current size, max size & autoextend details for the tablespace in issue.
select file_name, bytes/1024/1024, maxbytes/1024/1024, autoextensible from dba_data_files where
tablespace_name=<tablespace_name>;
FILE_NAME
BYTES/1024/1024 MAXBYTES/1024/1024
AUT
-------------------------------------------------- --------------- ------------------ --/u13_PHASTAGE/oradata/PHASTAGE/mac_dat_06.dbf
780.007813
780.789063 YES
/u05_PHASTAGE/oradata/PHASTAGE/mac_dat_05.dbf
457
459 YES
/u17_PHASTAGE/oradata/PHASTAGE/mac_dat_08.dbf
465
4000 YES
a) For Databases on UNIX Files Systems
i) Check the disk space available in the mounts based on the file names from the above query.
catlmsxp137 | PHASTAGE | /export/home/oracle > df -k|egrep '/u13|/u05|/u17'
/dev/vx/dsk/PHASTAGE_dg/u13_PHASTAGE 61341696 55741136 5556808 91%
/u13_PHASTAGE
/dev/vx/dsk/PHASTAGE_dg/u05_PHASTAGE 67108864 63737904 3344688 96%
/u05_PHASTAGE
/dev/vx/dsk/PHASTAGE_dg/u17_PHASTAGE 125829120 98479747 25640095 80%
/u17_PHASTAGE
ii) From the above output we can make out that mount /u17 25GB free space is available, we can add /
resize a datafile on mount point /u17.
iii) Now we need to determine how much space we need to add, so that tablespace is below 85%
threshold.
Execute the below attached query.

Tus age.s ql

Sample output of tusage.sql script


Enter value for tbs: MAC_DAT
old 21: and dts.tablespace_name = '&tbs'
new 21: and dts.tablespace_name = 'MAC_DAT'
TABLESPACE_N AVAIL
USED
FREE Used % FREE_PC Required MB
------------ ---------- ---------- ---------- ------- ------- ----------MAC_DAT 6119.00781 6036.07813 82.9296875 98.64 1.36 982.26057
iv) To add datafile
ALTER TABLESPACE <tablespace_name> ADD DATAFILE '\path\filename.dbf'
SIZE 99m AUTOEXTEND ON NEXT 100m MAXSIZE 982m;
v) To resize an existing datafile
ALTER DATABASE DATAFILE '\path\filename.dbf' RESIZE 982M;
vi) To increase the max size for an existing datafile
ALTER DATABASE DATAFILE '\path\filename.dbf' AUTOEXTEND ON MAXSIZE 982M;
NOTE: where 982M stands for the amount of free space to be added to datafile such that it is below the
warning threshold.
b) For ASM instances
i) Fetch the file name including the DG name, current size, max size & autoextend details for the
tablespace in issue.
Select file_name, bytes/1024/1024, maxbytes/1024/1024, autoextensible from dba_data_files where
tablespace_name='KANA_DATA';
FILE_NAME
BYTES/1024/1024 MAXBYTES/1024/1024 AUT
------------------------------------------------------------ --------------- ------------------ --+PODS_T1_DATA_01/pods/datafile/kana_data.418.713289465
25600
25600 YES
+PODS_T1_DATA_01/pods/datafile/kana_data.437.719292757
6436
25600 YES

ii) Determine the free space available on +PODS_T1_DATA_01 DG before adding the datafile.
Connect to the ASM instance and determine the free space at DG level as below

> . oraenv
ORACLE_SID = [PODS1] ? +ASM1
catlmsxp200 | +ASM1 | /export/home/oracle
> asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block
AU Total_MB Free_MB Req_mir_free_MB
Usable_file_MB Offline_disks Name
MOUNTED EXTERN N
N
512 4096 1048576 2332692 666994
0
0 PODS_T1_DATA_01/

666994

As we can notice from the output above, the DG PODS_T1_DATA_01 has 666 GB free space.
iii) To add datafile
ALTER TABLESPACE <tablespace_name> ADD DATAFILE 'DG name'
AUTOEXTEND ON NEXT 100m MAXSIZE 982m;

SIZE 99m

iv) To resize an existing datafile


ALTER DATABASE DATAFILE '\path\filename.dbf' RESIZE 982M;
v) To increase the max size for an existing datafile
ALTER DATABASE DATAFILE '\path\filename.dbf' AUTOEXTEND ON MAXSIZE 982M;
NOTE: where 982M stands for the amount of free space to be added to datafile such that it is below the
warning threshold.

Temp Tablespace Management


When we get the error message for Temp tablespace
ORA-1652: unable to extend temp segment by 64 in tablespace TEMP_DIS
1. Perform the below steps.
i) Check the status of the sort segment utilization
select TABLESPACE_NAME,TOTAL_BLOCKS,USED_BLOCKS,FREE_BLOCKS from
v$sort_segment;
TABLESPACE_NAME
TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS
------------------------------- ------------ ----------- ----------TEMP
10547520
82944 10464576
TEMP_DIS
3843456
5184 3838272
If USED_BLOCKS = TOTAL_BLOCKS, find which user and statement is using the temporary
sort segment by following query.
SELECT a.username, a.sid, a.serial#, a.osuser, b.tablespace, b.blocks, c.sql_text
FROM v$session a, v$tempseg_usage b, v$sqlarea c
WHERE a.saddr = b.session_addr
AND c.address= a.sql_address
AND c.hash_value = a.sql_hash_value
ORDER BY b.tablespace, b.blocks;
ii) There are two ways of solving this error:
a) Add tempfiles, increase the size of the current ones or enable auto extend.
b) Tune the queries/statements so that the sort operations are done in memory and not on the disk.
iii) Determine the disk utilization refer 2) a) for UFS instances and 2) b) for ASM instances under data
tablespace management.
iv) Adding tempfile
For UFS instances

ALTER TABLESPACE <tablespace_name> ADD TEMPFILE '\path\filename.dbf' SIZE 99m


AUTOEXTEND ON NEXT 100m MAXSIZE XXXM;
For ASM instances

ALTER TABLESPACE <tablespace_name> ADD TEMPFILE 'DG Name' SIZE 99m


AUTOEXTEND ON NEXT 100m MAXSIZE XXXM;

For UFS and ASM instances

To resize an existing tempfile


ALTER DATABASE TEMPFILE '\path\filename.dbf' RESIZE XXXM;
To increase the max size for an existing datafile
ALTER DATABASE TEMPFILE '\path\filename.dbf' AUTOEXTEND ON MAXSIZE XXXM;
Note: For temp tablespace, always set max size when ever autoextend is on.

UNDO Tablespace Management


When ever we receive the UNDO tablespace alert from Sitescope as below

Warning: TableSpace PUTS1 Monitor >=90% Status: matched: Used Pct -&gt; 100, 2.547 sec, 1 row,
tablespace_name -> UNDOTBS2, Free MB -> 16, Used Pct -> 100 (10....
Perform the below steps to resolve the issue.
1) Identify the sessions that are occupying most of the UNDO

SELECT a.sid, b.name, a.value,c.program, c.username


FROM v$sesstat a, v$statname b, v$session c
WHERE a.statistic# = b.statistic# AND (a.statistic# = 176 or a.statistic# = 134) and a.sid=c.sid and
c.username not in ('DBSNMP','SYS') ORDER BY a.value DESC 9;
Output of step 1 query can be used for performance analysis if required.
2) Below query can be used for sizing the UNDO Tablespace

SELECT ((UR * (UPS * DBS)) + (DBS * 24))/1024/1024 AS "MB"


FROM (SELECT value AS UR FROM v$parameter WHERE name = 'undo_retention'),
(SELECT (SUM(undoblks)/SUM(((end_time - begin_time)*86400))) AS UPS FROM v$undostat),
(select block_size as DBS from dba_tablespaces where tablespace_name=
(select upper(value) from v$parameter where name = 'undo_tablespace'));
MB
---------14937.8262
Output of the step 2, query shows that 14.9 GB is needed for UNDO Tablespace
Note: For adding / resizing datafile please refer to the 2 (a) & (b) sections of the Data tablespace management.

You might also like