Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Get Length of a Row

Oracle Database Tips by Donald BurlesonSeptember 15, 2015

Question:  I need to get the length of a particular row in Oracle.  I am not aware of how to collect size(bytes) for a particular row. 

I know that I can use dbms_stats to get the avg_row_len, but I need to compute the actual row length for a specific row. 

I don't just need the data space used by a row, I want to know the actual space consumed, a real row length.  I need to actual row length, not a guess or an average.  

Answer:  For detailed row length internals, you must use BBED and look inside the block data structures, count the internal pointer and data space used by the row.  

Here is a working example of computing the row length in a case where the name and datatype of each row are known in advance:  

select
nvl(dbms_lob.getlength(CASE_DATA),0)+1 +
     nvl(vsize(CASE_NUMBER   ),0)+1 +
     nvl(vsize(CASE_DATA_NAME),0)+1 +
     nvl(vsize(LASTMOD_TIME_T),0)+1
     "Total bytes per row"
from
    mytab
where
    case = 123;

You will also see free-space at the end of a data block (as defined by PCTFREE or ASSM, and you may also need to dump multiple data blocks of the row is chained (fragmented) into multiple data blocks.  

Here is a PL/SQL procedure that sums individual row lengths to compute the average row length on demand.  

For any particular row, you can compute the row length by summing these values for each row column, and guess by simply looking at the datatype.

  1.  VARCHAR row size:  A VARCHAR2 you can use a length function, and you can also use instr and nvl(vsize) to see a string length:

    select
        length(last_name)
    from
        emp
    where emp_id = 123;  

    select
    nvl(vsize(last_name),0),
    from
        emp where emp_id = 123;
        
  2.  NUMBER row size:  For a number data type, you can see the precision, and guess the actual bytes used  
  3.  For a CLOB you can use the dbms_lob.get_length function


 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster