- Newest
- Most votes
- Most comments
There are several reasons why your data files size (663.422 GiB) is much larger than the sum of individual tables in your schema (0.00308 GiB):
-
Other schemas: Your second query only checks tables in one specific schema ('SCHEMA_OWNER'), but your database likely contains many other schemas with their own tables.
-
Other segment types: Your query only counts segments of type 'TABLE', but databases also contain indexes, LOBs (Large Objects), partitions, and other segment types that consume space.
-
Unused allocated space: Oracle tablespaces can have space allocated but not yet used by segments. By default, Oracle tablespaces are created with auto-extend turned on and no maximum size, which can lead to excessive growth.
-
Temporary tablespaces: Your database has temp files (0.684 GiB) that are used for sorting operations and other temporary storage needs.
To address the space issue:
-
Identify large segments: Run queries against DBA_SEGMENTS to identify the largest segments across all schemas and segment types.
-
Resize tablespaces: You can resize permanent tablespaces using the
resize_datafileorautoextend_datafileprocedures, and temporary tablespaces usingresize_temp_tablespace,resize_tempfile, orautoextend_tempfileprocedures. -
Set appropriate maximum sizes: Specify an appropriate maximum size for permanent and temporary tablespaces to prevent excessive growth.
-
Consider hybrid partitioning: For large tables with historical data, you might want to implement hybrid partitioning to move older data to external storage like Amazon EFS.
-
Monitor space usage: Regularly monitor your tablespace usage to prevent unexpected growth.
Note that in RDS for Oracle, the maximum size of a single file is limited to 16 TiB due to the ext4 filesystem used by the instance.
Sources
Resizing tablespaces, data files, and temp files - Amazon Relational Database Service
Optimize your database storage for Oracle workloads on AWS, Part 2: Using hybrid partitioning and ILM data movement policies | AWS Database Blog
RDS for Oracle limitations - Amazon Relational Database Service
answered a year ago
Hi Mike, The query you are using to find the space utilization in your RDS ORACLE instance mentioned in this re:Post basically uses view dba_data_files , dba_temp_files , v$controlfile and size occupied in the ADUMP, BDUMP, DATA_PUMP_DIR directory to calculate their size and give output as sum. However when you are using the query below :
select sum( bytes)/10241/10241/1024 GB
from dba_tables t
Inner join dba_segments s
On table_name =segment_name and t.owner =s.owner
Where segment_type='TABLE'
And s.owner='SCHEMA_OWNER'
You are only calculating the size of the tables which are owned by the 'SCHEMA_OWNER' , you need to consider all schemas in your database , further you are only considering to calculate size of TABLES only what about indexes?
A better approach would be that you query your dba_data_files view and dba_free_space to see the actual physical space consumed in the database. Sample query below :
select
"Reserved_Space(GB)", "Reserved_Space(GB)" - "Free_Space(GB)" "Used_Space(GB)",
"Free_Space(GB)"
from(
select
(select sum(bytes/(1014*1024*1024)) from dba_data_files) "Reserved_Space(GB)",
(select sum(bytes/(1024*1024*1024)) from dba_free_space) "Free_Space(GB)"
from dual
);
From above output if the Reserved_Space is quite more than the used_space that indicates you have lot of sufficient space in the datafiles , you can then try to resize the tablespace below their high water mark using query like below :
alter tablespace <tablespace_name> resize <size in GB>;
If you get error while resizing then you will have to remove the fragmentation to bring the high water mark down and then retry the resize operation.
Regarding how to remove fragmentation please review this article
If you just want to know the space occupied by each user in your RDS Oracle instance then run below query and review :
select owner, sum(bytes)/1024/1024 Size_MB from dba_segments group by owner;
Relevant content
asked a year ago
asked 2 years ago
asked 3 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 years ago
