Which version of Oracle ?

The second query has to do a trunc() and a to_date()
on every single row.  The first only has to do a to_char
on every single row.  There is a CPU difference between
the two queries and if you run the execution plan through
v9 with cpu_costing, you will find a difference in cost -
though probably not enough to agree with your clock test.

A simple test on 8.1.7.4 and 9.2.0.2 where I created a
table of 128,000 rows with a date column scattered inside
a single date showed that one query used about twice
the CPU of the other in v9, and four times in v8.  (Unfortunately,
in all cases, the CPU reported by Oracle was consistently larger
than the elapsed time reported by SQL*Plus).


First check, though, is the test repeatable, or did
something happen elsewhere to affect the elapsed time.
(e.g. was one tested subject to a lot of delayed block
cleanout).



NB - The execution plan shown is not the plan for either
of the two statements, and I am fairly sure that neither
statement could actually return 120,000 rows in 10 ms.
Do your timings refer to a test where you changed
the query to do a count() ?




Regards

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

Coming soon one-day tutorials:
Cost Based Optimisation
Trouble-shooting and Tuning
Indexing Strategies
(see http://www.jlcomp.demon.co.uk/tutorial.html )

____UK_______March 19th
____UK_______April 8th
____UK_______April 22nd

____USA_(FL)_May 2nd


Next Seminar dates:
(see http://www.jlcomp.demon.co.uk/seminar.html )

____USA_(CA, TX)_August


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


----- Original Message -----
To: "Multiple recipients of list ORACLE-L" <[EMAIL PROTECTED]>
Sent: 05 March 2003 06:33


> Dear all,
>
> Please find below the 2 queries :
>
> select dep_date from test_date1
> where to_char(dep_date,'dd-mon-yyyy') = '12-jan-2002'
>
> select dep_date from test_date1
> where TRUNC(dep_date) = to_DATE( '12-jan-2002','dd-mon-yyyy')
>
> The execution plan for both the queries shows a FTS on test_date1.
>
> Execution Plan
> ----------------------------------------------------------
>    0      SELECT STATEMENT Optimizer=CHOOSE
>    1    0   SORT (AGGREGATE)
>    2    1     TABLE ACCESS (FULL) OF 'TEST_DATE1'
>
> The number of rows to be retrieved are 120010.
>
> The first query took 10msec to execute whereas the second took about
2
> secs.
>
> Could anyone help me figure out what the problem would be.
>
> TIA
>
> Best Regards
> Jai

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jonathan Lewis
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to