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: Naveen Nahata <naveen_nahata_at_mindtree.com>
Date: Sun, 22 Sep 2002 22:38:22 -0800
Message-ID: <F001.004D6349.20020922223822@fatcity.com>




RE: count(*)



I think this kind of huge volume of insertions can only take place if the application is doing a batch processing, so the issue of contention should not come.
 
if it is something like recording to page-hits or web-hits, then obviously the table will slow down the things a lot.
 
i don't have experience of huge DBs but 3 million rows an hour means 72 million rows in a day, which means 2.1 billion rows a month! this means it is recording some kind of transactions mostly web hits on a very popular web-site. what logic will force someone like to do a count(*) on such a table?
 
my gut feeling is that count(*) must be unnecessary, and simply because it is available easily in Informix(according to the poster), the application has somehow found a reason to use it
 
regards
naveen
-----Original Message-----
From: Craig Munday [mailto:Craig.Munday@ecard.com.au]
Sent: Monday, September 23, 2002 5:29 AM
To: Multiple recipients of list ORACLE-L
Subject: RE: count(*)

Hi

Depending on how the transactions are defined I do not think that you will be able to achieve the throughput as the single row will be a point of serialisation.

Cheers,
Craig.


-----Original Message-----
From: Naveen Nahata [mailto:naveen_nahata@mindtree.com]
Sent: Saturday, 21 September 2002 12:04 AM
To: Multiple recipients of list ORACLE-L
Subject: RE: count(*)


What about having a separate table with a single column and a single row to
store only the count, and increment and decrement it using a row trigger on
Insert and deletes?

that way select count(*) will be very fast, the only ovehead will of the
trigger, which i think should be offset by the performance gained by the
select.

Regards
naveen

-----Original Message-----
Sent: Friday, September 20, 2002 6:24 PM
To: Multiple recipients of list ORACLE-L


Rishi,

Do records get deleted from this table?  If not, you could simply add an
additional column that gets populated by a sequence, add an index on that
column, and select max() from that column.  Even better, simply query
'select sequence_name,last_number from user_sequences' to get the last value
used.  You may need to check whether sequence caching makes a difference
with this query.

Otherwise, Dennis gave some good advice.

Hope this helps.

Tom Mercadante
Oracle Certified Professional


-----Original Message-----
Sent: Thursday, September 19, 2002 5:04 PM
To: Multiple recipients of list ORACLE-L



Sent: Thursday, September 19, 2002 2:48 PM
To: 'ORACLE-L@fatcity.com'


Rishi - I've encountered this as well. I think the problem is the fact that
you are pounding millions of rows into the table. When you ask for a count,
Oracle won't give you an approximate answer, but insists on giving you a
precise answer as of the moment you hit return. You are right, your query
can actually slow performance. No, to my knowledge Oracle doesn't maintain a
record of the number of rows in the table, my guess being that could become
a performance bottleneck.
   My recommendation would be to ask very precisely what is to be achieved
with the count. As you noticed, the count will lag reality by quite awhile.
Perhaps the application could maintain the count. I have quite a few batch
programs that will display a running counter. If only an approximate count
is needed, there may be an alternate method, like looking at how many
segments are used and calculating. Just some thoughts.

Dennis Williams
DBA
Lifetouch, Inc.
dwilliams@lifetouch.com <mailto:dwilliams@lifetouch.com>


-----Original Message-----
[mailto:Rishi.Jain@VerizonWireless.com]
Sent: Thursday, September 19, 2002 1:28 PM
To: Multiple recipients of list ORACLE-L


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@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@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: DENNIS WILLIAMS
  INET: DWILLIAMS@LIFETOUCH.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@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: Mercadante, Thomas F
  INET: NDATFM@labor.state.ny.us

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@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: Naveen Nahata
  INET: naveen_nahata@mindtree.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@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: Naveen Nahata
  INET: naveen_nahata_at_mindtree.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 Mon Sep 23 2002 - 01:38:22 CDT

Original text of this message

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