Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Need a Fast Row Count
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