Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to optimize this query?

Re: How to optimize this query?

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: 5 Aug 2003 23:24:00 -0700
Message-ID: <1a75df45.0308052224.5da053d0@posting.google.com>


ed.prochak_at_magicinterface.com (Ed prochak) wrote

> Billy,
>
> when testing for performance, don't use COUNT(). Make the query fetch
> rows. (COUNT() can be optimised such that no rows are fetched, making
> the query SEEM fast.)

Yes Ed. I also did test that with a 'SELECT *'. It was also sub-second. Should have mentioned it.

In fact, I usually do as you suggest, however I then wrap the 'SELECT *' as a sub-select into a 'SELECT count(*)'.

As for the COUNT(*) - the only thing that I understand is eliminated, is the transfer of the actual data to you. The only overhead added is Oracle counting the rows. Thus it is IMO a fair technique to use to test the basic performance of the query (FIRST_ROWS aside) when not taking network traffic into consideration. I often use it when dealing with large volume reports (aka detailed reports) - something which I btw find very illogical. A report of more than 100 lines ceases to provide information and turns into meaningless data.

--
Billy
Received on Wed Aug 06 2003 - 01:24:00 CDT

Original text of this message

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