Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: A question about performance
Tiffany,
A good rule of thumb is that if a query returns >5-20% of the rows in a table, a full table scan will be faster.
If a query returns between 5 and 20%, test each execution plan to see which is faster.
You will have to determine how many of your rows have subscr_id > 0 to know which plan may be faster.
Try this:
SELECT
(taba.row2 / tab.COUNT(1)) x 100 "PERCENT_SELECTED"
FROM
SUBSCRIBER tab, (SELECT COUNT(1) row2 FROM subscriber WHERE subscr_id > 0) taba;
The definitive test would be to run each statement and trace it using TKPROF to see which is more economical.
A quick and dirty way would be to run each in SQL*Plus with SET TIMING ON first. Whichever is faster wins.
Jack
ocp x 2
Senior @ xol.com
-----Original Message-----
From: Yosi Greenfield [mailto:yosi_at_comhill.com]
Sent: Wednesday, June 21, 2000 10:59 AM
To: Multiple recipients of list ORACLE-L
Subject: Re: A question about performance
Hi,
The optimizer will probably ignore the index and do a full table scan
anyway.
If not, it would have to do at least two reads (index and data) and still
return every row of the table. In any case, leave out the where clause - it
could only hurt you.
hth
yosi
TiffanyDu_at_pcdc.com.tw wrote:
> Hi All:
> There is a question about performance.
> Table name : subscriber , primary key : subscr_id , with
> over 5000000 records .
>
> CASE 1 : select *
> from subscriber ;
> (FULL TABLE SCAN)
>
> CASE 2 : select *
> from subscriber
> where subscr_id > 0 ;
> (USE INDEX)
>
> Could anyone tell me which ones performance is better , or
> they are the same ??
>
> Thank you in advance.
>
>
> Tiffany
> E-mail tiffanydu_at_pcdc.com.tw
>
>
> --
> Author: =?big5?B?VGlmZmFueSBEdSAoIKf5p0qq4iAp?=
> INET: TiffanyDu_at_pcdc.com.tw
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
-- Author: Yosi Greenfield INET: yosi_at_comhill.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You mayReceived on Wed Jun 21 2000 - 10:41:52 CDT