Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Need a Fast Row Count

Re: Need a Fast Row Count

From: Chris Hamilton <ToneCzar_at_erols.com>
Date: 2000/03/23
Message-ID: <jdskdso75ku0sifkjq4050uv9olecpr1i1@4ax.com>#1/1

On Thu, 23 Mar 2000 09:06:48 -0700, Gary Brumfield <g.brumfield_at_lmco.com> wrote:

>Is there any other way than "select count(*) from <table>" to return the
>number of rows in an Oracle table? This takes forever to run (>3
>minutes) on a table that has over 3 million rows. I guess it has to do
>a full table scan to determine the correct number of rows and in a read
>consistent manner. It would be OK even if we got a count that was
>fairly close.
>
>Any Ideas or Insight?

If you do an "analyze table XXX estimate statistics" every night or even twice a day on the table in question, you could do:

select num_rows from user_tables where table_name = 'XXX';

That would return the approximate row count as of the last analyze (stored in the Last_Analyzed column in the same dictionary view, User_Tables).

Chris



Christopher Hamilton
Oracle DBA -- Sandbox.com
chamilton_at_sandbox-inc.com
http://www.sandbox.com/ Received on Thu Mar 23 2000 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US