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: Count(*) is very slow

Re: Count(*) is very slow

From: Andreas Kyritz <AKyritz_at_easy-soft-dresden.de>
Date: Wed, 21 Oct 1998 16:32:10 +0200
Message-ID: <70kt8b$ift$1@news.ipf.net>


Hi Billy,

Billy Verreynne schrieb in Nachricht <70karf$3md$1_at_hermes.is.co.za>...
>
>A SELECT count(*) tells the database engine to count the number of rows in
a
>table. Not the number of index entries. :-)
>

It doesn't matter, how the database engine counts the rows, but they SHOULD DO IT FAST.
On my oracle system the 'select count(*) from ...' command is a dangerous one, if there more than 50.000 rows in the table. 8-)

I've analyzed the command with EXPLAIN PLAN. It seems that it's not possible to prevent the fulltablescan.
(Select Count(PRIMARY_KEY) from ATABLE, Select Count(PRIMARY_KEY) from ATABLE where ALWAYS_TRUE_CONDITION, ...)

The summary is: Don't use 'Select Count(*) from ATable', if it's possible.

Thanks for your help

--
Andreas Kyritz
AKyritz_at_easy-soft-dresden.de Received on Wed Oct 21 1998 - 09:32:10 CDT

Original text of this message

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