Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating Average Row Length in Oracle 10g

78 views
Skip to first unread message

Nag

unread,
Jun 9, 2009, 2:38:47 PM6/9/09
to
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

Jonathan Lewis

unread,
Jun 9, 2009, 3:14:40 PM6/9/09
to

"Nag" <naga....@gmail.com> wrote in message
news:36c2aca6-179f-4068...@r3g2000vbp.googlegroups.com...


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.

select
3 +
(
nvl(c1,0) +
nvl(c2,0) +
nvl(c3,0) +
nvl(c4,0)
) / ct
from
(
select
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
from
t1
)
;

The value 3 is "column count - 1";

--
Regards

Jonathan Lewis
http://jonathanlewis.wordpress.com

Author: Cost Based Oracle: Fundamentals
http://www.jlcomp.demon.co.uk/cbo_book/ind_book.html

The Co-operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html


Mark D Powell

unread,
Jun 10, 2009, 10:07:09 AM6/10/09
to
On Jun 9, 3:14 pm, "Jonathan Lewis" <jonat...@jlcomp.demon.co.uk>
wrote:
> "Nag" <naga.cha...@gmail.com> wrote in message
> 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 --

0 new messages