Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Roshan.

Asked: October 09, 2018 - 9:26 am UTC

Last updated: October 16, 2018 - 2:19 am UTC

Version: 12.2.0

Viewed 1000+ times

You Asked

Hi,

I am trying to use the script below to analyze the data consumed for a table since I am planning the storage capacity for a datawarehouse. Using this value(for every table), I will then be able to plan data for 18 months.
I am writing a script to monitor the database usage from a specific point in time.
Ref: https://docs.oracle.com/database/121/ARPLS/d_space.htm#ARPLS68110

Grateful if you can help with the script

SET SERVEROUTPUT ON

SET VERIFY OFF

DECLARE

v_object_owner           VARCHAR2(30) := UPPER('&1');,

   v_object_name              VARCHAR2(30)  := UPPER('&2');,

   v_object_type              VARCHAR2(30)  := UPPER('&3');,

   v_partition_name           VARCHAR2(30) DEFAULT NULL,

   v_start_time                TIMESTAMP DEFAULT NULL,

   v_end_time                 TIMESTAMP DEFAULT NULL,

   v_interval                 DSINTERVAL_UNCONSTRAINED DEFAULT NULL,

   v_skip_interpolated       VARCHAR2(30) DEFAULT 'FALSE',

   v_timeout_seconds          NUMBER DEFAULT NULL,

   v_single_datapoint_flag    VARCHAR2(30) DEFAULT 'TRUE') ,

v_timepoint TIMESTAMP,

  v_space_usage NUMBER,

  v_space_alloc NUMBER,

  v_quality VARCHAR(20))

 

DBMS_SPACE.OBJECT_GROWTH_TREND (

   object_owner =>v_ object_owner          ,

   object_name       =>v_object_name                 ,

   object_type       => v_ object_type     ,

   partition_name => v_partition_name         ,

   start_time => v_start_time             ,

   end_time  => v_end_time              ,

   interval => v_intercal              ,

   skip_interpolated => v_skip_interpolated     ,

   timeout_seconds => v_timeout_seconds     ,

   single_datapoint_flag => v_single_datapoint_flag) ;

RETURN object_growth_trend_table PIPELINED; 

 

DBMS_OUTPUT.PUT_LINE('object_name                    :' || v_object_name );

DBMS_OUTPUT.PUT_LINE('object_type                    :' || v_object_type);

DBMS_OUTPUT.PUT_LINE('object_owner             :' || v_object_owner);

DBMS_OUTPUT.PUT_LINE('start time             :' || v_start_time );

DBMS_OUTPUT.PUT_LINE('end_time             :' || v_end_time );

DBMS_OUTPUT.PUT_LINE('The time at which the statistic was recorded             :' || v_timepoint);

DBMS_OUTPUT.PUT_LINE('The space used by data             :' || v_space_usage);

DBMS_OUTPUT.PUT_LINE('The size of segment including overhead and unused space            :' || v_space_alloc);

 

TYPE object_growth_trend_row IS RECORD(

  timepoint TIMESTAMP,

  space_usage NUMBER,

  space_alloc NUMBER,

  quality VARCHAR(20));

END;

/


Thanks,

Roshan

and Connor said...

You'll be pleased to know its much easier than that.

This is a pipelined function, so you can query it like a table

SQL> select *
  2  from
  3  DBMS_SPACE.OBJECT_GROWTH_TREND (
  4     object_owner=>'SCOTT',
  5     object_name=>'EMP',
  6     object_type=>'TABLE');

TIMEPOINT                                                                   SPACE_USAGE SPACE_ALLOC QUALITY
--------------------------------------------------------------------------- ----------- ----------- ----------
10-SEP-18 02.16.51.356000 PM                                                       8192       65536 GOOD


Tutorial for pipelined functions here

https://livesql.oracle.com/apex/livesql/file/tutorial_GS1U5KY647O601AZ0CGDQTKJX.html

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, October 10, 2018 - 7:34 am UTC

Hi, many thanks for the response. I would like to know if this 'tool' will be useful to calculate

1. data unit volume within different type
2. Calculate data growth.

https://docs.oracle.com/cd/E11882_01/doc.112/e26211/app_size.htm#DMAOG301

Also, how can I proceed in planning the storage for datawarehouse database? Should I use this tool to measure the size of table and then the growth(bytes) for around 18 months on the source before migrating those tables on the datawarehouse server?

Thanks,

Roshan
Connor McDonald
October 13, 2018 - 4:34 am UTC

The tool manages *existing* consumption, it does not estimate future storage.

So you could use it to get an assessment of *current* growth rate and use that as an input to predicting future growth rate.

Roshan Bisnath, October 15, 2018 - 4:00 pm UTC

Thanks for the update. Sorry to bother you again. Could you please help me in designing the tablespaces to cater for 18 months data?

Below is the data collected from the OBJECT_GROWTH procedure from 1 Aug to 10 Oct
The data was stable for some tables as shown below
Table Space usage space allocated
BO_GL_BALANCE 1144007499 1159725056
CB_REVENUE_CCBS 1904706666 1905262592
BOOST_CAMPAIGN 31804 65536
BUS_CUST_INCL 714858 786432
CB_ARTICLE_GROUPS 5412 65536
CB_ARTICLES 20251 65536



For some tables, as from 04th Oct 2018, the space usage was fluctuating

CBS_CBASE_DETAILS

29-SEP-18 14.34.17.142850000
13394260 13631488
30-SEP-18 17.30.51.428564000 13394260 13631488
01-OCT-18 20.27.25.714278000 13394260 13631488
02-OCT-18 23.23.59.999992000 13394260 13631488
04-OCT-18 02.20.34.285706000 13087948 13087948
05-OCT-18 05.17.08.571420000 13285022 14680064
06-OCT-18 08.13.42.857134000 13386212 14680064
07-OCT-18 11.10.17.142848000 13468133 14680064
08-OCT-18 14.06.51.428562000 13500032 14680064
09-OCT-18 17.03.25.714276000 13555242 14680064
10-OCT-18 19.59.59.999990000 13624948 14680064

Kindly advise how should I design the different tablespacesin terms of

1. TABLESPACE TYPE(SMALLFILE/BIGFILE)
2. filesize
3. increment(mb)
4. max filesize
5. blocksize(2/4/8/16/32) KB
6. "Extent allocation(automatic/uniform)
7. If uniform, extent size?"
8. "Logging/Nologging/

BO_GL_BALANCE
CB_REVENUE_CCBS
BOOST_CAMPAIGN
BUS_CUST_INCL
CB_ARTICLE_GROUPS
CB_ARTICLES
CBS_CBASE_DETAILS
?

Thanks,

Roshan



Connor McDonald
October 16, 2018 - 2:19 am UTC

1. TABLESPACE TYPE(SMALLFILE/BIGFILE)
=> doesn't really matter, but given the sizes, smallfile should be fine

2. filesize
=> doesn't matter, let them autoextend and pick an appropriate max size for you (but the default of 32G should be fine as well)

3. increment(mb)
=> depends on spurts of growth, and the database will try pre-allocate so you never have to pause for extension.

4. max filesize
=> see 2

5. blocksize(2/4/8/16/32) KB
=> unless you a reason not to, go with the default (8k)

6. "Extent allocation(automatic/uniform)
=> go with the default (auto)

7. If uniform, extent size?"
=> see 6

8. "Logging/Nologging/
=> Go with LOGGING. If particular tables need NOLOGGING, do it at table level.

You can see from above ... in general, just go with defaults. Easier to manage, and easier to get help from Support if you ever have a problem, because the environment is easily replicated.

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database