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: NUM_ROWS vs COUNT(*) anomaly

Re: NUM_ROWS vs COUNT(*) anomaly

From: Andreas Michler <Andreas.Michler_at_adicom.de>
Date: Thu, 13 Jan 2000 11:23:29 +0100
Message-ID: <387DA7A1.E86446A0@adicom.de>


You must check the stastistics on the table;

analyze table table_a estimate statistics; or
analyze table table_a compute statistics;

after this they are synchron.

Do this every day one time ,if your optimizer is cost based. An insert or delete does not modify the value of num_rows in the data-dictionary.
Don't use this field for exact counting for your application. It is only used bei internal Optimizer to generate an execution plan.

So long

"s. hunter" wrote:

> Hi,
>
> I noticed a weird anomaly when checking that the data in my database had
> loaded properly.
>
> If I do
>
> SELECT table_name, num_rows
> FROM user_tables
> WHERE table_name='table_A';
>
> I get a value for num_rows of 5424908.
>
> If, however I just do
>
> SELECT count(*)
> FROM table_A;
>
> I get a value of 5424804 (incidentally, the correct value).
>
> OK, so I know that num_rows is from the data dictionary and the count is
> directly on the table, but why are the values different? Any ideas??
>
> Thanks,
>
> Sarah

--



ADICOM Informatik GmbH
Andreas Michler
Wiesfleckenstr. 34
72336 Balingen
Tel: 07433/9977-57,Fax: -90
E-Mail: Andreas.Michler_at_adicom.de
http:\\www.adicom.de
Received on Thu Jan 13 2000 - 04:23:29 CST

Original text of this message

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