Oracle
  Home arrow Oracle arrow Page 5 - Developing and Implementing Applicatio...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Developing and Implementing Applications, continued
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2006-02-16

    Table of Contents:
  • Developing and Implementing Applications, continued
  • Switching Consumer Groups
  • Editing Stored Outlines
  • The Golden Rule for Space Calculations
  • Sizing the Objects
  • Estimating Space Requirements for Indexes
  • Sizing Tables That Contain Large Objects (LOBs)
  • Using Object Views

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Developing and Implementing Applications, continued - Sizing the Objects
    (Page 5 of 8 )

    To effectively manage your space, all you need to do is select a set of space values that meet the criteria described in the preceding sections. Once the space allocations are finalized, separate them by tablespace. Here’s an example:

    create tablespace DATA_1M
    datafile '/u01/oracle/VLDB/data_1m.dbf'
    size 100M
    extent management local uniform size 1M;

    create tablespace DATA_MEDIUM
    datafile '/u01/oracle/VLDB/data_4m.dbf'
    size 400M
    extent management local uniform size 4M;
    create tablespace DATA_LARGE
    datafile '/u01/oracle/VLDB/data_16m.dbf' size 16000M
    extent management local uniform size 16M;

    In this example, three separate DATA tablespaces are created, with extent sizes of 1MB, 4MB, and 16MB. If you need to create a table 3MB in size, you can either create it with three 1MB extents in DATA_1M or with one 4MB extent in DATA_4M. A table that will grow to 10MB can be placed in DATA_4M.

    As your tables grow in size, your default storage clauses will grow in a consistent fashion, following the space rules and your standards for extent sizes. DATA_64M would be next, followed by DATA_256M and DATA_1G. Use the same extent sizes across your databases to ease space management of your entire database environment.

    As the extent sizes grow, the distribution of extent sizes across tablespaces will usually result in a separation of table types—small static tables will be isolated in the tablespaces with small extent sizes. Large transaction-processing tables (or their partitions) will be segregated to the large extent size tables, simplifying later management and tuning activities.

    In the following sections you will see guidelines for estimations of the space usage for your objects. Because the target sizes (1MB, 4MB, 16MB, and so on) are not close together, the following estimations do not include highly detailed calculations.

    NOTE

    You can set the database block size at the tablespace level. You must set the block size during the tablespace creation, and you must have already created a buffer cache for the block size. Be sure the extent sizes you choose account for the largest block size in use in the database. Limiting the usage of nonstandard block sizes in the database will simplify cross-database maintenance and your sizing procedures.

    Estimating Space Requirements for Tables

    As of Oracle Database 10g, you can use the CREATE_TABLE_COST procedure of the DBMS_ SPACE package to estimate the space required by a table. The procedure determines the space required for a table based on attributes such as the tablespace storage parameters, the tablespace block size, the number of rows, and the average row length. The procedure is valid for both dictionary-managed and locally managed tablespaces.

    There are two versions of the CREATE_TABLE_COST procedure (it is overloaded so you can use the same procedure both ways). The first version has four input variables: tablespace_name, avg_row_size, row_count, and pct_free. Its output variables are used_bytes and alloc_bytes. The second version’s input variables are tablespace_name, colinfos, row_count, and pct_free; its output variables are used_bytes and alloc_bytes. Descriptions of the variables are provided in the following table:

     

    Parameter

    Description

    tablespace_name

    The tablespace in which the object will be created.

    avg_row_size

    The average length of a row in the table.

    colinfos

    The description of the columns.

    row_count

    The anticipated number of rows in the table.

    pct_free

    The pctfree setting for the table.

    used_bytes

    The space used by the table’s data. This value includes the overhead due to the pctfree setting and other block features.

    alloc_bytes

    The space allocated to the table’s data, based on the tablespace characteristics. This value takes the tablespace extent size settings into account.

    For example, if you have an existing tablespace named USERS, you can estimate the space required for a new table in that tablespace. In the following example, the CREATE_TABLE_COST procedure is executed with values passed for the average row size, the row count, and the pctfree setting. The used_bytes and alloc_bytes variables are defined and are displayed via the DBMS_ OUTPUT.PUT_LINE procedure:

    declare
      
    calc_used_bytes NUMBER;
       calc_alloc_bytes NUMBER;
    begin
      
    DBMS_SPACE.CREATE_TABLE_COST (
           
    tablespace_name => 'USERS',
           avg_row_size => 100,
          
    row_count => 5000,
          
    pct_free => 10,
          
    used_bytes => calc_used_bytes,
           alloc_bytes => calc_alloc_bytes
       );
      
    DBMS_OUTPUT.PUT_LINE('Used bytes: '||calc_used_bytes);
       DBMS_OUTPUT.PUT_LINE('Allocated bytes: '||calc_alloc_bytes);
    end;
    /

    The output of this PL/SQL block will display the used and allocated bytes calculated for these variable settings. You can easily calculate the expected space usage for multiple combinations of space settings prior to creating the table.

    NOTE

    You must use the set serveroutput on  command to enable the script’s output to be displayed within a SQL*Plus session.

    More Oracle Articles
    More By McGraw-Hill/Osborne


       · This article is an excerpt from the book "Oracle Database 10g DBA Handbook,"...
     

    Buy this book now. This article is excerpted from chapter five of the book Oracle Database 10g DBA Handbook, written by Kevin Loney and Bob Bryla (McGraw-Hill/Osborne, 2005; ISBN: 0072231459). Check it out today at your favorite bookstore. Buy this book now.

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway