niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Replacing a subselect with Collections
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Francesco M.
*nix forums beginner


Joined: 01 Apr 2005
Posts: 36

PostPosted: Thu Feb 24, 2005 7:48 am    Post subject: Re: Replacing a subselect with Collections Reply with quote

Hello,
thanks for your replies. Well both. I'm interested to give a try to
pl-sql collections and to make the query run a bit faster. I'm
surprised to see that the saving is really negligible if I switch from
the subselect to a pl-sql variable.
As I mentioned, from my Java background I'm accustomed to cache
everything which can be reused....but it seems that with Oracle engine
it works differently.
Thanks
Francesco
Back to top
mikharakiri_nospaum@yahoo
*nix forums beginner


Joined: 05 Feb 2005
Posts: 46

PostPosted: Wed Feb 23, 2005 10:13 pm    Post subject: Re: Replacing a subselect with Collections Reply with quote

If anag_ptr.desc_ptr is indexed and desc_ptr = snap.ptr_a are very
selective predicates, then your query as fast as it can possibly be (on
server side). Changing those scalar subqueries into pl/sql would
achieve only performance degradation caused by context switch.
Back to top
DA Morgan
*nix forums Guru


Joined: 06 Mar 2005
Posts: 1042

PostPosted: Wed Feb 23, 2005 4:27 pm    Post subject: Re: Replacing a subselect with Collections Reply with quote

fmarchioni@libero.it wrote:

Quote:
Hi all oracle users,
I have a cursor which fetches a few thousand records.
Inside it I have a subselect which is used for decoding one field.


CURSOR snap_crs IS
SELECT decode (snap.id, 1,
(select code_ptr from anag_ptr where desc_ptr = snap.ptr_a),

(select code_ptr from anag_ptr where desc_ptr = snap.ptr_b)
),
..... other fields....


My question is: since * anag_ptr * is a static table (doesn't ever
change),
is it worthy to replace the subselect with values taken from a
Collection ?

Having a Java background I would use an Hashtable to insert couples
(code_ptr,desc_ptr)...but what about pl/sql ? can I do the same ?

Thanks a lot
Francesco

Is there a specific performance issue you are trying to address or is
this just for academic interest? My suggestion ... try it ... benchmark
it.

But be very careful about statements like "doesn't ever change." I have
seen more than a few Java coders fileted by that statement.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Back to top
Francesco M.
*nix forums beginner


Joined: 01 Apr 2005
Posts: 36

PostPosted: Wed Feb 23, 2005 8:26 am    Post subject: Replacing a subselect with Collections Reply with quote

Hi all oracle users,
I have a cursor which fetches a few thousand records.
Inside it I have a subselect which is used for decoding one field.


CURSOR snap_crs IS
SELECT decode (snap.id, 1,
(select code_ptr from anag_ptr where desc_ptr = snap.ptr_a),

(select code_ptr from anag_ptr where desc_ptr = snap.ptr_b)
),
..... other fields....


My question is: since * anag_ptr * is a static table (doesn't ever
change),
is it worthy to replace the subselect with values taken from a
Collection ?

Having a Java background I would use an Hashtable to insert couples
(code_ptr,desc_ptr)...but what about pl/sql ? can I do the same ?

Thanks a lot
Francesco
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 5:27 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Could I use a host variable for replacing the table name ... cdngo@sopragroup.com IBM DB2 3 Thu Jul 06, 2006 3:28 pm
No new posts ORA-04031 with Collections and SGA Settings - Part II Dereck L. Dietz Server 6 Sat Jul 01, 2006 8:01 pm
No new posts ORA-04031 with Collections and SGA Settings Dereck L. Dietz Server 3 Thu Jun 29, 2006 9:04 pm
No new posts oracle 9: collections syntax in proc? matt@mailinator.com Server 5 Mon Jun 26, 2006 3:37 pm
No new posts Collections problems in Oracle 10g/XE Sten Server 0 Wed Jun 21, 2006 10:17 pm

Personal Finance | Personal Car Finance | Debt Consolidation | Secured Loans | MPAA
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2899s ][ Queries: 20 (0.0590s) ][ GZIP on - Debug on ]