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

Home -> Community -> Mailing Lists -> Oracle-L -> Puzzling execution plan

Puzzling execution plan

From: Don Granaman <granaman_at_cox.net>
Date: Sat, 12 Jun 2004 02:16:54 -0400
Message-ID: <02f101c450ba$47d75510$6401a8c0@dilbert>


(Oracle 9.2.0.4) This doesn't make sense to me...

Table: Call it MYTAB - with about 50 million rows and 12 GB or so. Column: Call it INSERT_DATE (not quite, but close) Primary key: via single column unique index on sequence-generated column - call id PK_ID
Index: on INSERT_DATE - call it MYTAB_IDX01 Statistics: Fresh - and attempted several ways - via DBMS_STATS, analyze table MYTAB estimate statistics for table for all indexes, <the latter> + for all indexed columns, with sample size up to 40 percent, etc.

Query 1: select PK_ID from MYTAB where INSERT_DATE > trunc(sysdate) Query 2: select PK_ID from MYTAB where INSERT_DATE > to_date('11-JUN-2004','DD-MON-YYYY')
Query 3: select PK_ID from MYTAB where INSERT_DATE > sysdate -1

Query 1 : *Always* does a full table scan - and takes forever. (What was actually wanted.)
Query 2 : *Always* does a full table scan - and takes forever. (Same logic/results as Q1, but more "cumbersome".) Query 3 : *Always* does an index range scan on MYTAB_IDX01 - and takes a minute or less. (Not the same logic at all, but it does finish!)

I tried all these later in the day also (~11 PM) when the results would be fairly close (about 0.07% of the records) - with the same results.

How does this make sense? What might make an optimizer with fresh statistics so badly munge the execution plan for Q1 & Q2? This was in a database with no tweaks to OIC/etc. A hint "fixes" Q1 and Q2, but it seems one should not be necessary.

-Don Granaman

puzzled OraSaurus



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--

Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
Received on Sat Jun 12 2004 - 01:31:33 CDT

Original text of this message

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