Re: How can I count rows fast ?

From: Carl Gohringer <cgohring_at_lucifer>
Date: Fri, 10 Jun 1994 13:20:25 GMT
Message-ID: <Cr6nq2.Iv3_at_nl.oracle.com>


derwand_at_sap-ag.de (Guido Derwand) writes:
: Is there a faster method to count rows in a table than using SQL
: 'SELECT COUNT(*)' in Oracle V. 6 or 7 ? I've heard from some
: expirience with using 'SELECT COUNT(<index>)' to be faster, but
: I couldn't reproduce this (there seems to be no difference).
:
: Is there a chance to make it faster with a b-tree analysis ?
:
: How ever, I'm interested in every possibility (just mail it to me or
: post it in this group).
:
: Guido Derwand (email: derwand_at_sap-ag.de)
:

Rather than doing a count(*), do a count(<column>).

where <column> is a column with an index on it.

This can be resolved with the index alone, then, and prevent a full table scan.

--
regards,
Carl
+-----------------------------------------------------------------------------+
Carl Gohringer, 
Oracle UK, The Oracle Centre, The Ring, Bracknell, Berkshire, England, RG121BW
Internet   : cgohring_at_uk.oracle.com    
+-----------------------------------------------------------------------------+
Received on Fri Jun 10 1994 - 15:20:25 CEST

Original text of this message