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(*)

Re: select count(*)

From: Dave Wotton <Dave.Wotton_at_dwotton.nospam.clara.co.uk>
Date: 2000/07/31
Message-ID: <isih5.3982$_8.454811@nnrp3.clara.net>#1/1

Yong wrote in message <8lsd65$rto$1_at_news.sinet.slb.com>...
>
>You probably remembered wrong. You seem to be talking about group by after
>the where clause. *That* will suppress an index scan.

Sigh .... c'mon guys, let's check our answers before we potentially mislead people. 5 minutes investigation reveals ...

select region, count(*)
from employees
where emp_id between 'P' and 'Q'
group by region

Rows Execution Plan

-------  ---------------------------------------------------
      0  SELECT STATEMENT   GOAL: CHOOSE
   2864 SORT (GROUP BY)
   4507 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID)
               OF 'EMPLOYEES'
   4508     INDEX   GOAL: ANALYZED (RANGE SCAN)
                OF 'EMPLOYEES$EMP_ID' (NON-UNIQUE)

However, I agree that the indexes are only used to *select* the rows for sorting and are not used in the sort/grouping operation itself.

(As before, example is from Oracle 8.1.5, but it applies to Oracle 7 too).

Dave.

--
If you reply to this posting by email, remove the "nospam" from my email
address first.
Received on Mon Jul 31 2000 - 00:00:00 CDT

Original text of this message

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