Вы находитесь на странице: 1из 4

1.

SHOW THE USED SAPCE / FREE SPACE PER DATAFILE


set linesize 150
COLUMN file_name format A60
COLUMN free_space_mb format 999999.90
COLUMN allocated_mb format 999999.90
COLUMN used_mb format 999999.90
SELECT SUBSTR (df.NAME, 1, 60) file_name, df.bytes / 1024 / 1024 allocated_mb,
((df.bytes / 1024 / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024 , 0))
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024 , 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+)
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
UNION ALL
select file_name, bytes/1024/1024 allocated_mb,user_bytes/1024/1024 used_mb,
((bytes/1024/1024) - (user_bytes/1024/1024)) free_space_mb
from dba_temp_files;
set linesize 150
COLUMN file_name format A60
COLUMN free_space_mb format 999999.90
COLUMN allocated_mb format 999999.90
COLUMN used_mb format 999999.90
SELECT SUBSTR (df.NAME, 1, 60) file_name, df.bytes / 1024 / 1024 / 1024 allocate
d_mb,
((df.bytes / 1024 / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024 / 1024, 0)
)
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024 / 1024, 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+)
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
UNION ALL
select file_name, bytes/1024/1024/1024 allocated_mb,user_bytes/1024/1024/1024 us
ed_mb,
((bytes/1024/1024/1024) - (user_bytes/1024/1024/1024)) free_space_mb
from dba_temp_files;
2. Check Schemas
select owner, sum(bytes)/1024/1024/1024 schema_size_gig
from
dba_segments
group by
owner;
SELECT tablespace_name,
Sum(bytes)/1024/1024/1024 AS total_size_Gb
FROM dba_segments
WHERE owner='PROD' ;

3. HOW CAN WE CALCULATE ARCHIVELOG SIZE EACH DAY/HOUR?


This is not a difficult idea for someone who work as DBA, I just wish more idea
for discussion and sharing . Some Idea using V$LOG.BYTES and V$ARCHIVED_LOG.*
but I believe V$ARCHIVED_LOG view be able to help:
Archivelog size each day:
SQL> select trunc(COMPLETION_TIME) TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/1024 SIZE
_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME) order by 1;
TIME SIZE_MB
---------- ---------2011-02-12 71797.87
2011-02-13 75880.52
2011-02-14 73569.37
2011-02-15 76776.81
2011-02-16 73959.86
2011-02-17 69969.71
2011-02-18 74677.10
2011-02-19 75474.95
2011-02-20 77967.07
2011-02-21 67802.70
Archivelog size each hour:
SQL> alter session set nls_date_format = 'YYYY-MM-DD HH24';
Session altered.
SQL> select trunc(COMPLETION_TIME,'HH24') TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/10
24 SIZE_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME,'HH24') order by
1;
TIME SIZE_MB
------------- ---------2011-02-21 00 6396.65
2011-02-21 01 2797.31
2011-02-21 02 2010.45
2011-02-21 03 1871.77
2011-02-21 04 1481.5
2011-02-21 05 2868.20
2011-02-21 06 2363.89
2011-02-21 07 4269.26
2011-02-21 08 2469.08
2011-02-21 09 3007.06
2011-02-21 10 3561.97
2011-02-21 11 2530.57
2011-02-21 12 3509.08
2011-02-21 13 3022.5
2011-02-21 14 3514.97
2011-02-21 15 4057.45
2011-02-21 16 3021.27
2011-02-21 17 4014.31
2011-02-21 18 4011.66
2011-02-21 19 4008.10
2011-02-21 20 3015.46
That is just my samples ^^

How about archive log size each of day/hour on RAC?- Using GV$ARCHIVED_LOG ???
SQL> select INST_ID, RECID, NAME, to_char(COMPLETION_TIME,'YYYY-MM-DD HH24:MI:SS
'), ARCHIVAL_THREAD# , blocks * block_size from GV$ARCHIVED_LOG order by COMPLET
ION_TIME;
INST_ID RECID NAME TO_CHAR(COMPLETION_ ARCHIVAL_THREAD#
---------- ---------- -------------------------------------------------- ------------------ ---------------4 258572 +ARCH/DB/4_73214_617849235.dbf 2011-02-21 20:29:52 4
2 258572 +ARCH/DB/4_73214_617849235.dbf 2011-02-21 20:29:52 4
1 258572 +ARCH/DB/4_73214_617849235.dbf 2011-02-21 20:29:52 4
3 258572 +ARCH/DB/4_73214_617849235.dbf 2011-02-21 20:29:52 4
1 258573 +ARCH/DB/1_55739_617849235.dbf 2011-02-21 20:44:22 1
3 258573 +ARCH/DB/1_55739_617849235.dbf 2011-02-21 20:44:22 1
4 258573 +ARCH/DB/1_55739_617849235.dbf 2011-02-21 20:44:22 1
2 258573 +ARCH/DB/1_55739_617849235.dbf 2011-02-21 20:44:22 1
NO!!! - What do we see? - When we want to calculate archivelog size on RAC, we j
ust use V$ARCHIVED_LOG view. So, on RAC:
Archivelog size each day:

SQL> select trunc(COMPLETION_TIME) TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/1024 SIZE


_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME) order by 1;
TIME SIZE_MB
---------- ---------2011-02-12 71797.87
2011-02-13 75880.52
2011-02-14 73569.37
2011-02-15 76776.81
2011-02-16 73959.86
2011-02-17 69969.71
2011-02-18 74677.10
2011-02-19 75474.95
2011-02-20 77967.07
2011-02-21 67802.70
Archivelog size each hour:
SQL> alter session set nls_date_format = 'YYYY-MM-DD HH24';
Session altered.
SQL> select trunc(COMPLETION_TIME,'HH24') TIME, SUM(BLOCKS * BLOCK_SIZE)/1024/10
24 SIZE_MB from V$ARCHIVED_LOG group by trunc (COMPLETION_TIME,'HH24') order by
1;
TIME SIZE_MB
------------2011-02-21 00
2011-02-21 01
2011-02-21 02
2011-02-21 03
2011-02-21 04
2011-02-21 05
2011-02-21 06
2011-02-21 07
2011-02-21 08
2011-02-21 09

---------6396.65
2797.31
2010.45
1871.77
1481.5
2868.20
2363.89
4269.26
2469.08
3007.06

2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21
2011-02-21

10
11
12
13
14
15
16
17
18
19
20

3561.97
2530.57
3509.08
3022.5
3514.97
4057.45
3021.27
4014.31
4011.66
4008.10
3015.46

3. ASM
select name,total_mb,free_mb,state from v$asm_diskgroup;
NAME
TOTAL_MB
FREE_MB STATE
------------------------------ ---------- ---------- ----------ACFS
262144
159612 MOUNTED
DATASSD
147456
109260 MOUNTED
DATA
1835008
1010084 MOUNTED
OCRCRS
24576
23536 MOUNTED
RECO
1048576
884528 MOUNTED

SQL> select name,total_mb,free_mb, (free_mb/total_mb)*100 "%Free" from v$asm_dis


kgroup;
NAME
TOTAL_MB
FREE_MB
%Free
------------------------------ ---------- ---------- ---------ACFS
262144
159612 60.887146
DATASSD
147456
109260 74.0966797
DATA
1835008
1010084 55.0452096
OCRCRS
24576
23536 95.7682292
RECO
1048576
884528 84.3551636