Unix Technical Forum

How can I re-write this piece of code for better performance!?

This is a discussion on How can I re-write this piece of code for better performance!? within the Oracle Database forums, part of the Database Server Software category; --> This piece of code is taking a long time. Any help will be appreicate it. select * from ( ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 02:21 PM
lou_nyc
 
Posts: n/a
Default How can I re-write this piece of code for better performance!?

This piece of code is taking a long time. Any help will be appreicate
it.


select *
from (
select ssl_user_code,
ssl_user_code ssl,
i.container,
out_date,
cl.code length_code,
out_trucker_code,
decode ((select ih.in_date
from his_containers ih
where ih.container = i.container
and ih.container_id > i.container_id
and ih.container_id = (select min(ihh.container_id)
from his_containers ihh
where ihh.container_id >
i.container_id
and ihh.container =
i.container)), null,
(select ic.in_date
from inv_containers ic
where ic.container = i.container)) in_date,
decode ((select ih.in_trucker_code
from his_containers ih
where ih.container = i.container
and ih.container_id > i.container_id
and ih.container_id = (select min(ihh.container_id)
from his_containers ihh
where ihh.container_id >
i.container_id
and ihh.container =
i.container)), null,
(select ic.in_trucker_code
from inv_containers ic
where ic.container = i.container)) in_trucker_code,
decode ((select ih.chassis
from his_containers ih
where ih.container = i.container
and ih.container_id > i.container_id
and ih.container_id = (select min(ihh.container_id)
from his_containers ihh
where ihh.container_id >
i.container_id
and ihh.container =
i.container)), null,
(select ic.chassis
from inv_containers ic
where ic.container = i.container)) in_chassis
from his_containers i,
container_masters cm,
tml_container_lhts clht,
tml_container_lengths cl
where i.chassis is null and
i.out_mode = 'T'
and cm.container = i.container and
cm.lht_code = clht.code and
clht.length_code = cl.code and
decode ((select ih.container_id
from his_containers ih
where ih.container = i.container
and ih.container_id > i.container_id
and ih.container_id = (select min(ihh.container_id)
from his_containers ihh
where ihh.container_id >
i.container_id
and ihh.container =
i.container)), null,
(select ic.container_id
from inv_containers ic
where ic.container = i.container)) is not null
)
where ssl_user_code = 'ACL'
and ((out_date between to_date('01-MAR-05 00:00:00', 'DD-MON-RR
HH24:MI:SS')
and to_date('31-MAR-05 23:59:59', 'DD-MON-RR HH24:MI:SS'))
or (in_date between to_date('01-MAR-05 00:00:00', 'DD-MON-RR
HH24:MI:SS')
and to_date('31-MAR-05 23:59:59', 'DD-MON-RR HH24:MI:SS')))
and in_date is null

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-24-2008, 02:21 PM
Dave
 
Posts: n/a
Default Re: How can I re-write this piece of code for better performance!?


"lou_nyc" <lnlx@aol.com> wrote in message
news:1119465959.232854.316900@f14g2000cwb.googlegr oups.com...
> This piece of code is taking a long time. Any help will be appreicate
> it.
>
>
> select *
> from (
> select ssl_user_code,
> ssl_user_code ssl,
> i.container,
> out_date,
> cl.code length_code,
> out_trucker_code,
> decode ((select ih.in_date
> from his_containers ih
> where ih.container = i.container
> and ih.container_id > i.container_id
> and ih.container_id = (select min(ihh.container_id)
> from his_containers ihh
> where ihh.container_id >
> i.container_id
> and ihh.container =
> i.container)), null,
> (select ic.in_date
> from inv_containers ic
> where ic.container = i.container)) in_date,
> decode ((select ih.in_trucker_code
> from his_containers ih
> where ih.container = i.container
> and ih.container_id > i.container_id
> and ih.container_id = (select min(ihh.container_id)
> from his_containers ihh
> where ihh.container_id >
> i.container_id
> and ihh.container =
> i.container)), null,
> (select ic.in_trucker_code
> from inv_containers ic
> where ic.container = i.container)) in_trucker_code,
> decode ((select ih.chassis
> from his_containers ih
> where ih.container = i.container
> and ih.container_id > i.container_id
> and ih.container_id = (select min(ihh.container_id)
> from his_containers ihh
> where ihh.container_id >
> i.container_id
> and ihh.container =
> i.container)), null,
> (select ic.chassis
> from inv_containers ic
> where ic.container = i.container)) in_chassis
> from his_containers i,
> container_masters cm,
> tml_container_lhts clht,
> tml_container_lengths cl
> where i.chassis is null and
> i.out_mode = 'T'
> and cm.container = i.container and
> cm.lht_code = clht.code and
> clht.length_code = cl.code and
> decode ((select ih.container_id
> from his_containers ih
> where ih.container = i.container
> and ih.container_id > i.container_id
> and ih.container_id = (select min(ihh.container_id)
> from his_containers ihh
> where ihh.container_id >
> i.container_id
> and ihh.container =
> i.container)), null,
> (select ic.container_id
> from inv_containers ic
> where ic.container = i.container)) is not null
> )
> where ssl_user_code = 'ACL'
> and ((out_date between to_date('01-MAR-05 00:00:00', 'DD-MON-RR
> HH24:MI:SS')
> and to_date('31-MAR-05 23:59:59', 'DD-MON-RR HH24:MI:SS'))
> or (in_date between to_date('01-MAR-05 00:00:00', 'DD-MON-RR
> HH24:MI:SS')
> and to_date('31-MAR-05 23:59:59', 'DD-MON-RR HH24:MI:SS')))
> and in_date is null
>


too long - do a 10046 level 8 trace, see what you are waiting - learn how to
read an explain plan


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-24-2008, 02:27 PM
Mladen Gogala
 
Posts: n/a
Default Re: How can I re-write this piece of code for better performance!?

On Wed, 22 Jun 2005 11:45:59 -0700, lou_nyc wrote:

> This piece of code is taking a long time. Any help will be appreicate
> it.


I'll pray for you.

--
You can get more of what you want with a kind word and a gun than
you can with just a kind word. (Al Kapone)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:33 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com