RE: Determination of "deterministic"

  • From: John Hallas <John.Hallas@xxxxxxxxxxxxxxxxxx>
  • To: "yong321@xxxxxxxxx" <yong321@xxxxxxxxx>, "oracle-l@xxxxxxxxxxxxx" <oracle-l@xxxxxxxxxxxxx>
  • Date: Sat, 30 Oct 2010 08:46:17 +0100

Co-incidentally we had Julian Dyke on site today giving a seminar about 
execution plans and he made the same point about the deterministic keyword not 
actually performing any verification. Ric obviously makes a valid point that 
you would need unlimited resources to be able to correctly determine whether a 
function was deterministic or not but it does make you wonder what the 
'function' of the keyword is, perhaps it is only to be used in place of a 
comment.

John

www.jhdba.wordpress.com 

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Yong Huang
Sent: 29 October 2010 20:24
To: oracle-l@xxxxxxxxxxxxx
Subject: Determination of "deterministic"

A function can be marked as deterministic if you know the function always 
returns the same set of data when you pass the same values to its 
arguments (if any). If a function has certain keywords such as rownum 
or sysdate, it won't be deterministic even if you use the keyword 
"deterministic" in its definition:

SQL> create or replace function f return date
  2  deterministic
  3  as
  4  d date;
  5  begin
  6    select sysdate into d from dual;
  7    return d;
  8  end;
  9  /

Function created.

SQL> select f from dual;

F
-----------------
20101028 22:27:07

SQL> select f from dual;

F
-----------------
20101028 22:27:08

Thus, presence of "deterministic" is NOT related to the true meaning of 
the word "deterministic".

On the other hand, this query
select * from (select * from t order by id) where rownum <= 10;
is definitely deterministic from the user's perspective if id is unique, 
even though it has the word "rownum".

Is there a way for Oracle, or software in general, to determine whether 
a query is really deterministic, not by checking presence of certain 
keywords, but by some other means?

Yong Huang


      
--
//www.freelists.org/webpage/oracle-l



______________________________________________________________________
Wm Morrison Supermarkets Plc is registered in England with number 358949. The 
registered office of the company is situated at Gain Lane, Bradford, West 
Yorkshire BD3 7DL. This email and any attachments are intended for the 
addressee(s) only and may be confidential. 

If you are not the intended recipient, please inform the sender by replying to 
the email that you have received in error and then destroy the email. 
If you are not the intended recipient, you must not use, disclose, copy or rely 
on the email or its attachments in any way. 

This email does not constitute a contract in writing for the purposes of the 
Law of Property (Miscellaneous Provisions) Act 1989.

Our Standard Terms and Conditions of Purchase, as may be amended from time to 
time, apply to any contract that we enter into. The current version of our 
Standard Terms and Conditions of Purchase is available at: 
http://www.morrisons.co.uk/gscop

Although we have taken steps to ensure the email and its attachments are 
virus-free, we cannot guarantee this or accept any responsibility, 
and it is the responsibility of recipients to carry out their own virus checks. 
______________________________________________________________________
--
//www.freelists.org/webpage/oracle-l


Other related posts: