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: Questioning Oracle Documentation

Re: Questioning Oracle Documentation

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 10 Jul 2004 22:07:09 +0000 (UTC)
Message-ID: <ccppad$6r6$1@sparta.btinternet.com>

Is the example the same in the 9i manual ?

I believe 10g has mechanisms for promoting constant assignments to a position outside the loop - but possibly this only works in a restricted number of cases.

You might try:

    n := 15
    n := 15.0

c as a varchar2()
c as char(2) -- to match the size of '15'

-- 
Regards

Jonathan Lewis

http://www.jlcomp.demon.co.uk

http://www.jlcomp.demon.co.uk/faq/ind_faq.html
The Co-operative Oracle Users' FAQ

http://www.jlcomp.demon.co.uk/seminar.html
Optimising Oracle Seminar - schedule updated May 1st


"Daniel Morgan" <damorgan_at_x.washington.edu> wrote in message
news:1089492156.252777_at_yasure...

> In Tuning PL/SQL Applications for Performance
>
http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10807/12_tune.htm#LNPLS012
> I found the following and decided it could make a good demo for my
students.
>
> So here's what I wrote:
>
> DECLARE
>
> c CHAR(5);
> i PLS_INTEGER;
> j PLS_INTEGER;
> n NUMBER := 0;
>
> BEGIN
> BEGIN
> i := dbms_utility.get_time();
>
> FOR i IN 1 .. 10000000
> LOOP
> n := n + 15;
> END LOOP;
>
> j := dbms_utility.get_time() - i;
> dbms_output.put_line('n+15 = ' || TO_CHAR(j));
> END;
>
> BEGIN
> i := dbms_utility.get_time();
>
> FOR i IN 1 .. 10000000
> LOOP
> n := n+15.0;
> END LOOP;
>
> j := dbms_utility.get_time() - i;
> dbms_output.put_line('n+15.0 = ' || TO_CHAR(j));
> END;
>
> BEGIN
> i := dbms_utility.get_time();
>
> FOR i IN 1 .. 10000000
> LOOP
> c := 15;
> END LOOP;
>
> j := dbms_utility.get_time() - i;
> dbms_output.put_line('c=15 = ' || TO_CHAR(j));
> END;
>
> BEGIN
> i := dbms_utility.get_time();
>
> FOR i IN 1 .. 10000000
> LOOP
> c := TO_CHAR(15);
> END LOOP;
>
> j := dbms_utility.get_time() - i;
> dbms_output.put_line('c=TO_CHAR = ' || TO_CHAR(j));
> END;
>
> BEGIN
> i := dbms_utility.get_time();
>
> FOR i IN 1 .. 10000000
> LOOP
> c := '15';
> END LOOP;
>
> j := dbms_utility.get_time() - i;
> dbms_output.put_line('c=''15'' = ' || TO_CHAR(j));
> END;
> END;
> /
>
> Can anyone hazard a guess as to why I am getting the following
> result?
>
> n+15 = 201
> n+15.0 = 204
> c=15 = 38
> c=TO_CHAR = 304
> c='15' = 307
>
> Why is the implicit conversion, that we are being warned
> not to do the fastest?
>
> 10.1.0.2 on Win2K w/ 1GB RAM
>
> Daniel Morgan
>
Received on Sat Jul 10 2004 - 17:07:09 CDT

Original text of this message

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