Home » SQL & PL/SQL » SQL & PL/SQL » Query performance please Help!!!!!!
Query performance please Help!!!!!! [message #19926] Thu, 18 April 2002 08:39 Go to next message
aish
Messages: 44
Registered: March 2001
Member
Hi,

Can anybody tell be How to improve this query this is taking forever

select substr(d.name,1,14) "dist",
sum(r.room_net_sq_foot) "nsf",
sum(r.student_station_count) "sta",
sum(distinct(r.cofte)) "fte"
from b_fish_report r,
g_efis_organization d
where substr(r.organization_code,-2,2) = substr(d.code,-2,2) and
d.organization_type = 'CNTY' and
r.room_satisfactory_flag = 'Y' and
substr(d.code,-2,2) between '01' and '72'
-- rownum < 50
group by d.name, r.organization_code
order by d.name

The unique is defined on organization_type and organization_code

Thnnx
Aish
Re: Query performance please Help!!!!!! [message #19929 is a reply to message #19926] Thu, 18 April 2002 11:22 Go to previous messageGo to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
hi,

Which version of Oracle (8, 8i or 9i) are you using?

Do you have any indexes? If yes which one?

Which is the explain plan (in sqlplus do SET AUTOTRACE ON)?

Mike
Re: Query performance please Help!!!!!! [message #19941 is a reply to message #19926] Fri, 19 April 2002 07:00 Go to previous message
Sanjay Bajracharya
Messages: 279
Registered: October 2001
Location: Florida
Senior Member
Chances are you are NOT hitting the unique index as you are doing a SUBSTR on 'organization_code'.

Check your explain_plan.

Can you NOT use substr for 'organization_code' ? I don't know how your data is.
Previous Topic: split a long column into two rows
Next Topic: Error using Objects
Goto Forum:
  


Current Time: Fri Apr 26 04:48:39 CDT 2024