Thursday, April 10, 2014

Unit used to calculate space in SYS.DBA_TABLESPACE_USAGE_METRICS

Plese find how the initial SYS.DBA_TABLESPACE_USAGE_METRICS output look like, generally we get confused as what unit is used in the view and how we can convert the data into MB or GB so that the data is readable.

ORADB01>CLNDV10>SELECT TABLESPACE_NAME TBSP_NAME
, USED_SPACE
, TABLESPACE_SIZE TBSP_SIZE
, USED_PERCENT
FROM SYS.DBA_TABLESPACE_USAGE_METRICS  2    3    4    5
 6  ;

TBSP_NAME                      USED_SPACE  TBSP_SIZE USED_PERCENT
------------------------------ ---------- ---------- ------------
SYSAUX                              60784     524288    11.5936279
SYSTEM                              65456      524288    12.4847412
TEMP                                  384           524288     .073242188
TOOLS                                   8           524288    .001525879
UNDOTBS1                         536         524288   .102233887
USERS                               74896        524288    14.2852783

The unit used here is in blocks.

Please find the block size of database.


ORADB01>sho parameter block

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
db_block_buffers                     integer                          0
db_block_checking                    string                           FALSE
db_block_checksum                    string                           TRUE
db_block_size                        integer                               8192
db_file_multiblock_read_count        integer                          32

Here block size is 8Kb, in this case if we have to convert SYSAUX TBSP_SIZE to MB we need to divide 1024/8=128. That is 128 Blocks makes a MB, so the tablespace max extendable size is 524288/128=4096 MB (4GB).

Please find the script that shows the tablespace in GB as below. 

ORADB01>SELECT TABLESPACE_NAME TBSP_NAME
, USED_SPACE/128/1024 TBSP_USEDSPS_gb
, TABLESPACE_SIZE/128/1024 TBSP_SIZE_GB
, USED_PERCENT
FROM SYS.DBA_TABLESPACE_USAGE_METRICS  2    3    4    5  ;



TBSP_NAME                      TBSP_USEDSPS_GB TBSP_SIZE_GB USED_PERCENT
------------------------------ --------------- ------------ ------------
SYSAUX                              .463745117            4   11.5936279
SYSTEM                                .499389648           4   12.4847412
TEMP                                    .002929688            4   .073242188
TOOLS                                  .000061035            4   .001525879
UNDOTBS1                           .004089355            4   .102233887
        USERS                                   .571411133             4   14.2

No comments: