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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: count(*)

RE: count(*)

From: <Reginald.W.Bailey_at_jpmorgan.com>
Date: Thu, 19 Sep 2002 15:53:23 -0800
Message-ID: <F001.004D4761.20020919155323@fatcity.com>

Paula et al:

It could work if the analyze is done after the load using DBMS_STATS. Then the num_rows would be accurate. With the monitoring turned on , analyzing would be done on the
table if more than a certain percentage had changed. It is not an elegant solution. A more pratical one , if you're using SQL Loader, is to use a counter variable. If not using SQL Loader, then a synthetic key backed with a trigger and sequence, could suffice. It could give you the accurate count after a load by checking the NEXTVAL.sequence_name or CURRENTVAL.sequence_name. The method could be put in a procedure to improve efficiency.

Just a thought.

RWB Paula_Stankus_at_doh.state.fl.us_at_fatcity.com on 09/19/2002 05:38:24 PM

Please respond to ORACLE-L_at_fatcity.com

Sent by: root_at_fatcity.com

To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> cc:

That won't work if he is constantly loading data as analyze is going to take longer then just the count(*).  What about writing in the load process or a trigger itself a variable with a running total could use dbms_output to write it out to a file.  Starting with existing rowcount this would be the fastest as you would really not have any additional I/O - just a counter.

-----Original Message-----

[mailto:Reginald.W.Bailey_at_jpmorgan.com]
Sent: Thursday, September 19, 2002 5:34 PM To: Multiple recipients of list ORACLE-L

Try this:

select table_name, num_rows from dba_tables where table_name = [table_name];

[table_name] = the name of the table or a variable. This works if you are updating your statistics and you may also want monitoring turned on for the table.
It is easier to get the information from the data dictionary sometimes, than actually doing a count of rows. This is Oracle8i or above, right?

RWB Rishi.Jain_at_VerizonWireless.com_at_fatcity.com on 09/19/2002 01:28:27 PM

Please respond to ORACLE-L_at_fatcity.com

Sent by:  root_at_fatcity.com

To:   Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> cc:

Hi Gurus,

In one of our insert intensive application we are inserting around 3-4 million rows / hour. Also this app needs to do a count(*) of the tables every 10 minutes for verifying some application based logic. This is really killing us and it takes a lot of time.

Can you please guide me to a direction ( built in functions or something similar).

Actually this app is being ported from Informix. Informix can somehow keep a
trak of the count(*) of a  table in its header somewhere.

And yes I have tries count(1) , count(indexed_column) etc.

Thanks In Advance.

R.h
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: Rishi.Jain_at_VerizonWireless.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from).  You may also send the HELP command for other information (like subscribing).

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: Reginald.W.Bailey_at_jpmorgan.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from).  You may also send the HELP command for other information (like subscribing).

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: Reginald.W.Bailey_at_jpmorgan.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Sep 19 2002 - 18:53:23 CDT

Original text of this message

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