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: select count(*) optimization

Re: select count(*) optimization

From: g.r.s. deisz <g.r.s.deisz_at_ptt-telecom.unisource.nl>
Date: 1997/03/10
Message-ID: <5g0efj$3mr@pwxl01.telecom.ptt.nl>#1/1

In article <331D9E0D.4B3E_at_sprintmail.com>,

   jim nash <jimnash_at_sprintmail.com> wrote:
>Anyone know how to fool the optimizer into using a
>primary key access path to count all rows in a table?
>e.g.
> select count(*) from blah;
>
>In my case the rows are very long, the prim key is very short,
>and the full table scan brings the machine to its knobby knees.

The following might help:

select count(primary key) from blah;

(I suppose NULL values are not allowed in your PK, and you  have an index on PK)

Stefan.


Name      :G.R.S. Deisz
Phone     :+31-50-5855954
E mail    :G.R.S.Deisz_at_PTT-Telecom.Unisource.NL
DISCLAIMER:This statement is not an official statement from, nor
           does it represent an official position of, PTT Telecom BV.
Received on Mon Mar 10 1997 - 00:00:00 CST

Original text of this message

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