Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tablespace size in dba_data_files and DBA_HIST_TBSPC_SPACE_USAGE -why?

DeepCMar 15 2020 — edited Mar 16 2020

Can any expert explains the reason for the difference that I can see in the tablespace size from these two dynamic views? What is the correct space allocated to the tablespace and what is the current usage in that case and how much space is available here, currently.

From DBA_HIST_TBSPC_SPACE_USAGE

SELECT NAME, TS_SIZE_TOT_GB, TS_USED_GB,  TS_SIZE_TOT_GB - TS_USED_GB FREE_SPACE, RTIME, SYSDATE FROM (

SELECT ROUND ((DHTSU.tablespace_size * 32768) / 1024 / 1024/1024) ts_size_gb,

         ROUND ((DHTSU.tablespace_maxsize * 32768) / 1024 / 1024/1024) ts_size_tot_gb,

         ROUND ( (DHTSU.tablespace_usedsize * 32768) / 1024 / 1024/1024) ts_used_gb,

         DHTSU.RTIME,

         VT.NAME

FROM DBA_HIST_TBSPC_SPACE_USAGE DHTSU, V$TABLESPACE VT

WHERE DHTSU.TABLESPACE_ID= VT.TS#

AND DHTSU.RTIME = (SELECT MAX(DHTSU1.RTIME) FROM DBA_HIST_TBSPC_SPACE_USAGE DHTSU1 WHERE DHTSU.TABLESPACE_ID=DHTSU1.TABLESPACE_ID)

--ORDER BY rtime DESC

)

WHERE NAME ='MY_TABLESPACE'

The output is

NameTS_SIZE_TOT_GBTS_USED_GBFREE_SPACERTIMESYSDATE
MY_TABLESPACE130568333472303/15/2020 18:01:0315/03/2020 18:52:22

From dba_data_files

select round(sum(blocks*32768)/1024/1024/1024,0) size_gb,round(sum(user_blocks*32768)/1024/1024/1024,0) size_gb_used, tablespace_name from

dba_data_Files

where tablespace_name ='MY_TABLESPACE'

group by tablespace_name

The output is

Size_GBSize_GB_USED
Tablespace_Name
1115111151MY_TABLESPACE

Block size of the tablespace = 32768; Initial Extent =1048576; Next Extent= 1048576; Max Extent= 2147483645; Local/Uniform.

I was expecting DBA_DATA_FILES.SIZE_GB = DBA_HIST_TBSPC_SPACE_USAGE.TS_SIZE_TOT_GB i.e current allocated space size of the tablespace should be equal to sum of bytes of all underlying data files size. Not sure, why is the difference. Which is the correct value of the tablespace and what is the current usage in that case and how much space is available as of now.

There are 314 data files of this tablespace - 18 are autoextensible and 296 are not.

This post has been answered by Jonathan Lewis on Mar 16 2020
Jump to Answer
Comments
Post Details
Added on Mar 15 2020
4 comments
1,549 views