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

Home -> Community -> Usenet -> c.d.o.server -> Re: Freezing database statistics

Re: Freezing database statistics

From: Niall Litchfield <niall.litchfield_at_gmail.com>
Date: 31 Oct 2006 04:48:52 -0800
Message-ID: <1162298931.943030.14740@k70g2000cwa.googlegroups.com>

On Oct 31, 4:25 am, dbaplusp..._at_hotmail.com wrote: <snip>
> > select *
> > from orders
> > where order_date > sysdate - 1
> > ;
>
> > The SQL doesn't change, but if you freeze the statistics,
> > and keep taking orders, the CBO will eventually decide
> > that there are no order matching the requirement. (At
> > least, that's will be true from 10g onwards - earlier
> > versions treat most manipulations of sysdate as if it
> > were a bind variable, which would results in a 5% selectivity
> > in the example above).
>
> > --
> > Regards
>
> > Jonathan Lewis
> >http://jonathanlewis.wordpress.com
>
> > Author: Cost Based Oracle: Fundamentals
> >http://www.jlcomp.demon.co.uk/cbo_book/ind_book.html
>
> > The Co-operative Oracle Users' FAQ
> >http://www.jlcomp.demon.co.uk/faq/ind_faq.htmlI am not sure whether I understand you. How can using or not using
> statistics can give wrong result. Result may be slower but eventually
> all the orders in table whose order_date > sysdate - 1 will be shown.
> Please elaborate.

Oracle won't (or rather if it does its a bug) get the wrong result, however it may decide upon a pretty bad execution plan because it doesn't know what the spread of the data is.

cheers

Niall Litchfield
Oracle DBA
http://www.orawin.info/services Received on Tue Oct 31 2006 - 06:48:52 CST

Original text of this message

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