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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Explain Plan vs Actual Execution Plan

RE: Explain Plan vs Actual Execution Plan

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Fri, 21 Mar 2003 10:14:40 -0800
Message-Id: <24738.322727@fatcity.com>


This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2EFD5.BD322D90
Content-Type: text/plain;

        charset="iso-8859-1"

I'm open to abuse if I'm wrong, but I think that the intended distinction was:
let's assume table T with partitions P1 and P2 analyze table t compute statistics ; <--- global statistics

analyze table t partition (p1) compute statistics ; <--- local statistics on partition p1
analyze table t partition (p2) compute statistics ; <--- local statistics on partition p2

> -----Original Message-----
> From: Odland, Brad [mailto:Brad.Odland_at_qtiworld.com]
> 
> Please exlain the difference between local and global statistics.
> Is this statisitics on a partition? 
> 
> -----Original Message-----
> 
> Brad, you're absolutely correct.  Explain plan is what is 
> intended, but
> isn't what always happens.  It probably is most of the time, 
> but not always.
> I recently had a circumstance in which a long running job 
> (the explain plan
> of) was telling me it was reading from a big partitioned 
> table and using the
> index that it should have been using, but a 10046 trace 
> showed reads from a
> different index and no reads from the index identified by 
> explain plan.  A
> full analyze compute (using dbms_stats)  later, this job works fine.
> I suspect in my case the problem was with statistics.  The job was
> originally set up by the developer to add data each night, 
> then analyze the
> current partition.  The last time global stats were gathered 
> on this table
> was last October.  I suspect that over time with data loads 
> and updates the
> data distribution, etc. got skewed as compared to the global 
> stats, so the
> optimizer didn't have enough valid information to make a good choice.
> This query was reading data from 5 or 6 partitions of a 54 
> partition table.
> That's important information because a couple of weeks ago I 
> was reading the
> "Oracle 8i Designing and Tuning for Performance" document and 
> came across
> this statement:
> "Unless the query predicate narrows the query to a single 
> partition, the
> optimizer uses the global statistics.  Because most queries 
> are not likely
> to be this restrictive, it is most important to have accurate global
> statistics."
> Pretty interesting to think about.  It's gather stats global 
> and local from
> now on for me.

------_=_NextPart_001_01C2EFD5.BD322D90
Content-Type: text/html;

        charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>RE: Explain Plan vs Actual Execution Plan</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>I'm open to abuse if I'm wrong, but I think that the intended distinction was:</FONT>
<BR><FONT SIZE=2>let's assume table T with partitions P1 and P2</FONT>
<BR><FONT SIZE=2>analyze table t compute statistics ; &lt;--- global statistics</FONT>
</P>

<P><FONT SIZE=2>analyze table t partition (p1) compute statistics ; &lt;--- local statistics on partition p1</FONT>
<BR><FONT SIZE=2>analyze table t partition (p2) compute statistics ; &lt;--- local statistics on partition p2</FONT>
</P>

<P><FONT SIZE=2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; From: Odland, Brad [<A HREF="mailto:Brad.Odland_at_qtiworld.com">mailto:Brad.Odland_at_qtiworld.com</A>]</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Please exlain the difference between local and global statistics.</FONT>
<BR><FONT SIZE=2>&gt; Is this statisitics on a partition? </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Brad, you're absolutely correct.&nbsp; Explain plan is what is </FONT>
<BR><FONT SIZE=2>&gt; intended, but</FONT>
<BR><FONT SIZE=2>&gt; isn't what always happens.&nbsp; It probably is most of the time, </FONT>
<BR><FONT SIZE=2>&gt; but not always.</FONT>
<BR><FONT SIZE=2>&gt; I recently had a circumstance in which a long running job </FONT>
<BR><FONT SIZE=2>&gt; (the explain plan</FONT>
<BR><FONT SIZE=2>&gt; of) was telling me it was reading from a big partitioned </FONT>
<BR><FONT SIZE=2>&gt; table and using the</FONT>
<BR><FONT SIZE=2>&gt; index that it should have been using, but a 10046 trace </FONT>
<BR><FONT SIZE=2>&gt; showed reads from a</FONT>
<BR><FONT SIZE=2>&gt; different index and no reads from the index identified by </FONT>
<BR><FONT SIZE=2>&gt; explain plan.&nbsp; A</FONT>
<BR><FONT SIZE=2>&gt; full analyze compute (using dbms_stats)&nbsp; later, this job works fine.</FONT>
<BR><FONT SIZE=2>&gt; I suspect in my case the problem was with statistics.&nbsp; The job was</FONT>
<BR><FONT SIZE=2>&gt; originally set up by the developer to add data each night, </FONT>
<BR><FONT SIZE=2>&gt; then analyze the</FONT>
<BR><FONT SIZE=2>&gt; current partition.&nbsp; The last time global stats were gathered </FONT>
<BR><FONT SIZE=2>&gt; on this table</FONT>
<BR><FONT SIZE=2>&gt; was last October.&nbsp; I suspect that over time with data loads </FONT>
<BR><FONT SIZE=2>&gt; and updates the</FONT>
<BR><FONT SIZE=2>&gt; data distribution, etc. got skewed as compared to the global </FONT>
<BR><FONT SIZE=2>&gt; stats, so the</FONT>
<BR><FONT SIZE=2>&gt; optimizer didn't have enough valid information to make a good choice.</FONT>
<BR><FONT SIZE=2>&gt; This query was reading data from 5 or 6 partitions of a 54 </FONT>
<BR><FONT SIZE=2>&gt; partition table.</FONT>
<BR><FONT SIZE=2>&gt; That's important information because a couple of weeks ago I </FONT>
<BR><FONT SIZE=2>&gt; was reading the</FONT>
<BR><FONT SIZE=2>&gt; &quot;Oracle 8i Designing and Tuning for Performance&quot; document and </FONT>
<BR><FONT SIZE=2>&gt; came across</FONT>
<BR><FONT SIZE=2>&gt; this statement:</FONT>
<BR><FONT SIZE=2>&gt; &quot;Unless the query predicate narrows the query to a single </FONT>
<BR><FONT SIZE=2>&gt; partition, the</FONT>
<BR><FONT SIZE=2>&gt; optimizer uses the global statistics.&nbsp; Because most queries </FONT>
<BR><FONT SIZE=2>&gt; are not likely</FONT>
<BR><FONT SIZE=2>&gt; to be this restrictive, it is most important to have accurate global</FONT>
<BR><FONT SIZE=2>&gt; statistics.&quot;</FONT>
<BR><FONT SIZE=2>&gt; Pretty interesting to think about.&nbsp; It's gather stats global </FONT>
<BR><FONT SIZE=2>&gt; and local from</FONT>
Received on Fri Mar 21 2003 - 12:14:40 CST

Original text of this message

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