Re: Calculating Average Row Length in Oracle 10g
Date: Wed, 10 Jun 2009 07:07:09 -0700 (PDT)
On Jun 9, 3:14 pm, "Jonathan Lewis" <jonat..._at_jlcomp.demon.co.uk> wrote:
> "Nag" <naga.cha..._at_gmail.com> wrote in message
> > All,
> > We can get this by analyzing the tables in a schema and looking at the
> > column avg_row_len.
> > But, is there a sql so that I can calculate manually. In out
> > environment, we gather statistics once and use them all the time.
> > Thanks,
> > Naga
> Code like the following would give you roughly
> the correct answer for simple tables. Not sure
> how this should be altered to suit tables with
> LOB or LONG columns, or tables with more than
> 255 columns.
> 3 +
> nvl(c1,0) +
> nvl(c2,0) +
> nvl(c3,0) +
> ) / ct
> count(*) ct,
> sum(sys_op_opnsize(ID)) c1,
> sum(sys_op_opnsize(GRP)) c2,
> sum(sys_op_opnsize(SMALL_VC)) c3,
> sum(sys_op_opnsize(PADDING)) c4
> The value 3 is "column count - 1";
> Jonathan Lewishttp://jonathanlewis.wordpress.com
> Author: Cost Based Oracle: Fundamentalshttp://www.jlcomp.demon.co.uk/cbo_book/ind_book.html
> The Co-operative Oracle Users' FAQhttp://www.jlcomp.demon.co.uk/faq/ind_faq.html
Naga, your said that "we gather statistics once and use them all the time." However with 10g+ Oracle provides a scheduled task that automatically collects CBO statistics on your tables. Have you disabled it? Otherwise, Oracle will update the statistics. If you only collected statistics one time and used them forever on prior versions of Oracle and have upgraded you will be affected by this job.
HTH -- Mark D Powell -- Received on Wed Jun 10 2009 - 09:07:09 CDT