Return-Path: <oracle-l-bounce@freelists.org>
X-Original-To: oracle-l@orafaq.com
Delivered-To: oracle-l@orafaq.com
Received: from puck1183.startdedicated.com (localhost [127.0.0.1])
 by puck1183.startdedicated.com (Postfix) with ESMTP id D911A196109E
 for <oracle-l@orafaq.com>; Thu, 10 Oct 2013 22:20:38 +0200 (CEST)
Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180])
 by puck1183.startdedicated.com (Postfix) with ESMTP
 for <oracle-l@orafaq.com>; Thu, 10 Oct 2013 22:20:38 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B27D72662F;
 Thu, 10 Oct 2013 16:20:37 -0400 (EDT)
X-Virus-Scanned: Debian amavisd-new at turing.freelists.org
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id qKAr3J3HL3iM; Thu, 10 Oct 2013 16:20:37 -0400 (EDT)
Received: from turing.freelists.org (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 46D8426609;
 Thu, 10 Oct 2013 16:19:56 -0400 (EDT)
Received: with ECARTIS (v1.0.0; list oracle-l); Thu, 10 Oct 2013 16:19:14 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id CBBAA265F9
 for <oracle-l@freelists.org>; Thu, 10 Oct 2013 16:19:13 -0400 (EDT)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Cv5tV4Th5PwX for <oracle-l@freelists.org>;
 Thu, 10 Oct 2013 16:19:13 -0400 (EDT)
Received: from server519.appriver.com (server519d.appriver.com [72.32.252.14])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 7FA4A265EF
 for <oracle-l@freelists.org>; Thu, 10 Oct 2013 16:19:13 -0400 (EDT)
X-Note-AR-ScanTimeLocal: 10/10/2013 3:19:12 PM
X-Policy: GLOBAL - hotsos.com
X-Policy: GLOBAL - hotsos.com
X-Primary: ric.van.dyke@hotsos.com
X-Note: This Email was scanned by AppRiver SecureTide
X-Virus-Scan: V-
X-Note-SnifferID: 0
X-Note: TCH-CT/SI:0-64/SG:2 10/10/2013 3:18:14 PM
X-GBUdb-Analysis: 0, 69.93.176.68, Ugly c=0.457817 p=-0.905882 Source Normal
X-Signature-Violations:
 0-0-0-5000-c
X-Note-419: 15.6004 ms. Fail:1 Chk:1347 of 1347 total
X-Note: SCH-CT/SI:1-1347/SG:1 10/10/2013 3:19:01 PM
X-Note: Spam Tests Failed: 
X-Country-Path: UNITED STATES->UNITED STATES
X-Note-Sending-IP: 69.93.176.68
X-Note-Reverse-DNS: mail.hotsos.com
X-Note-Return-Path: ric.van.dyke@hotsos.com
X-Note: User Rule Hits: 
X-Note: Global Rule Hits: G340 G341 G342 G343 G347 G348 G455 
X-Note: Encrypt Rule Hits: 
X-Note: Mail Class: VALID
X-Note: Headers Injected
Received: from dummy.name; Thu, 10 Oct 2013 15:19:11 -0500
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 8bit
Subject: RE: Full scan vs index
Date: Thu, 10 Oct 2013 15:19:07 -0500
X-MimeOLE: Produced By Microsoft Exchange V6.5
Message-ID: <C970F08BBE1E164AA8063E01502A71CF021C1023@WIN02.hotsos.com>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: Full scan vs index
References: <FE4C2B093843BB4B873D754E5E0BE4DB6CCD76F0@DCSOSVMS02.dcso.org>
From: "Ric Van Dyke" <ric.van.dyke@hotsos.com>
To: <RStorey@DCSO.nashville.org>,
 "Oracle L" <oracle-l@freelists.org>
X-archive-position: 50906
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: ric.van.dyke@hotsos.com
Precedence: normal
Reply-To: ric.van.dyke@hotsos.com
List-help: <mailto:ecartis@freelists.org?Subject=help>
List-unsubscribe: <oracle-l-request@freelists.org?Subject=unsubscribe>
List-software: Ecartis version 1.0.0
List-Id: oracle-l <oracle-l.freelists.org>
X-List-ID: oracle-l <oracle-l.freelists.org>
List-subscribe: <oracle-l-request@freelists.org?Subject=subscribe>
List-owner: <mailto:steve.adams@ixora.com.au>
List-post: <mailto:oracle-l@freelists.org>
List-archive: <http://www.freelists.org/archives/oracle-l>
X-list: oracle-l

It's not about ROWS it's about BLOCKS.  How many blocks are being
accessed?  

Where are all the rows in the last query?  If the data is sparsely
populated then the FULL scan is a good idea. Generally speaking if the
data is in about 20% or more of the blocks of the table, then a FULL
scan is a good idea.  Oracle uses the CLUSTER_FACTOR of the index to
give it a clue about the density of the data. 

Oh, and the cost is relevant. 

And it's not the "CHOOSE" optimizer either, it's either IO or CPU.  The
setting of CHOOSE in 10 and above means CPU. 

Ric Van Dyke
Education Director 
Hotsos Enterprises, Ltd



-----Original Message-----
From: oracle-l-bounce@freelists.org
[mailto:oracle-l-bounce@freelists.org] On Behalf Of Storey, Robert
(DCSO)
Sent: Thursday, October 10, 2013 9:25 AM
To: Oracle L
Subject: Full scan vs index

Morning,
I don't understand the decision process for the CHOOSE optimizer
sometimes.  Maybe I'm just overlooking something fundamental about query
parsing. Here is the scenario and maybe someone can enlighten me.

Table A has 12 columns I have indexes on columns 1, 2, and 3. With
column 1 being the PK for the table. There are 596,785 records in the
table Column 1 is ordernum  number(12) Column 2 is Status char(1) with
possible values of I or A.
Column 3 is Lastname.

So, I do the following query.

Select count(*) from A where ordernum > 600000.  It returns 87000
records.  The explain plan shows a cost of 113 and the use of the
ordernum_pk.  Easy enough.

Select count(*) from A where Status = 'I'.  again, 435000 records, plan
is a cost of about 123 and uses the status index.

Now the part I don't get.

Select lastname from A where ordernum > 600000.  Now I get a Full table
Access of A to return 81K rows at a cost of 1152.  So, order of
magnitude worse and NO index usage.

I would think that even though I'm pulling a column out, it would still
use the index scan to get the target rows.  Why would adding the column
make it decide to scan full table vice index?

--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l


