sql query running for too long ..... [message #291554] |
Fri, 04 January 2008 16:31 |
yogeshse
Messages: 11 Registered: December 2005 Location: Chennai
|
Junior Member |
|
|
hi,
This query was not taking much time on oracle 9i. recently we moved to 10g. it ran for whole day and didn't complete. what could be reason ...
select * from customer_loctn c1
where src_id = 'AA'
and inact_dt > sysdate
and crx_code_type = 'TTR'
and crx_code_id ^= 'r'
and not exists
(select 'X' from customer_loctn c2
where c2.cust_id = c1.cust_id
and c2.src_id ^= 'AA'
and c2.inactv_dt > sysdate
and c2.loctn_id ^= c1.loctn_id
);
loctn_id is primary key and i also have index -
CUST_LOCTN_IX02 ON CUSTOMER_LOCTN("ZIP_CD", "STATE_CD", "INACT_DT", "SRC_ID", "CUST_ID")
|
|
|
|
Re: sql query running for too long ..... [message #291557 is a reply to message #291554] |
Fri, 04 January 2008 17:06 |
|
Kevin Meade
Messages: 2103 Registered: December 1999 Location: Connecticut USA
|
Senior Member |
|
|
sorry, forgot two other things.
Is that really the order of columns in your index. They look backwords to me for this query. I think maybe these are the two indexes you really need.
(src_id,crx_code_type,inact_dt,crx_code_id)
(cust_id,inactv_dt,src_id,loctn_id)
Also, is this really the query you are running or did you retype something cause looks like there might be spelling errors in your columns names. Do you really have these two date columns?
and inact_dt > sysdate
and c2.inactv_dt > sysdate
Maybe you do and it is OK, but seems somewhat co-incidental to have two date names different only by a missing last character V. At the very least that is a really crappy job done by your database modelers and/or DBAs to not enforce better naming standards for two different date columns in the same table. Of course there are possible reasons for this too as in maybe you inherited these names from a legacy systems in which case keeping the names like this is the right thing to do so I am not trying to beat anyone up here, just asking the question for clarification.
Kevin
|
|
|