Re: alternative to select count(*) for oracle 8

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 24 Apr 2003 06:44:18 -0700
Message-ID: <2687bb95.0304240544.5fe7660a_at_posting.google.com>


"Guido Konsolke" <Guido.Konsolke_at_triaton.com> wrote in message news:<1051178504.622482_at_news.thyssen.com>...
> "John Leslie" <johnleslie_at_madasafish.com> wrote...
> > Is there a better way to get the number of rows in a table, other than
> > using select count(*). For example, is there a dictionary table I can
> > read to accurately get the number of rows in a table?
> >
> > John
>
> Hi John,
>
> if you have statistics up to date, you can take a look at the column
> 'num_rows' in sys.user_tables.
>
> hth,
> Guido

The row count information in all_, dba_, and user_table is not guarenteed to be accurate. It's accuracy will depend on the type of sample taken, its age, and the activity on the table. Depending on your exact needs it may or may not be good enough. Even a count is accurated only to a specific point in time.

The cooperative FAQ article:
Is there a good way of counting the number of rows in a table ? at url => http://www.jlcomp.demon.co.uk/faq/count_rows.html   discusses how Oracle performs count(*) and possible ways to speed it up

Another article: Is there a simple way to produce a report of all tables in the database with current number of rows ? contains code to generate a select count for all or selected tables.

url => http://www.jlcomp.demon.co.uk/faq/count_all_rows.html

HTH -- Mark D Powell -- Received on Thu Apr 24 2003 - 15:44:18 CEST

Original text of this message