dbTalk Databases Forums  

Q: sys_context() vs. regular function call

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Q: sys_context() vs. regular function call in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Malcolm Dew-Jones
 
Posts: n/a

Default Q: sys_context() vs. regular function call - 05-15-2009 , 12:22 PM






Hello

Are there any differences between using sys_context in an SQL statement
and using a regular function? I'm not concerned here with the security
around setting the values, just the speed of accessing the value in an SQL
statement, and in particular whether Oracle has any special ability to
optimize calls to SYS_CONTEXT that it doesn't have with a user defined
function.

A did a couple of explain plans on some queries using a packaged function
and SYS_CONTEXT, and they both show up as basically the same plan (the
sys_context needed a to_number).


select * from my_table
where org_id = my_pkg.fn_wanted_org_id;

select * from my_table
where org_id = SYS_CONTEXT('APP_CTX','RPT_CENTRE_ID');


but maybe there are situations where it would make a speed difference that
I haven't considered.

Thanks for feedback.


Reply With Quote
  #2  
Old   
joel garry
 
Posts: n/a

Default Re: Q: sys_context() vs. regular function call - 05-18-2009 , 11:56 AM






On May 15, 10:22*am, yf... (AT) vtn1 (DOT) victoria.tc.ca (Malcolm Dew-Jones)
wrote:
Quote:
Hello

Are there any differences between using sys_context in an SQL statement
and using a regular function? *I'm not concerned here with the security
around setting the values, just the speed of accessing the value in an SQL
statement, and in particular whether Oracle has any special ability to
optimize calls to SYS_CONTEXT that it doesn't have with a user defined
function.

A did a couple of explain plans on some queries using a packaged function
and SYS_CONTEXT, and they both show up as basically the same plan (the
sys_context needed a to_number).

* * * * select * from my_table
* * * * where org_id = my_pkg.fn_wanted_org_id;

* * * * select * from my_table
* * * * where org_id = SYS_CONTEXT('APP_CTX','RPT_CENTRE_ID');

but maybe there are situations where it would make a speed difference that
I haven't considered.

Thanks for feedback.
I dunno, if the plan the way you are using it is the same, it should
be the same, but consider http://asktom.oracle.com/pls/asktom/...10400346203314
when you will be using it could make a differrence. I'm wondering
where http://yogeedba.blogspot.com/2008/05...ity-using.html
type of situations (extending your question to that sort of situation)
might make a difference, such as not being able to use an FBI or some
such thing. Some peoplesoft sites apparently have had issues that
desc indices are actually FBI's. Hopefully that's far enough away
from what you intend to not matter.

jg
--
@home.com is bogus.
Shackles are not restraints.
http://www3.signonsandiego.com/stori...nt-/?uniontrib


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.