Unix Technical Forum

Nested query taking long execution time!!!

This is a discussion on Nested query taking long execution time!!! within the Oracle Miscellaneous forums, part of the Oracle Database category; --> select count(distinct t1.ColA) from myTable1 t1 where ( select count( distinct t2.ColB ) from myTable1 t2 where SUBSTR(TO_CHAR(ID_TO_NUMBER(t1.ColA)),1,17) = ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 12:17 PM
qazmlp1209@rediffmail.com
 
Posts: n/a
Default Nested query taking long execution time!!!

select count(distinct t1.ColA)
from myTable1 t1
where
(
select count( distinct t2.ColB )
from myTable1 t2
where SUBSTR(TO_CHAR(ID_TO_NUMBER(t1.ColA)),1,17) =
SUBSTR(TO_CHAR(ID_TO_NUMBER(t2.ColA)),1,17)
) > 1 ;


I need to find the count of the rows in the Table(myTable1) where the
number of ColB values associated with the ColA value is more than 1.
myTable contains ColA and ColB as the key columns and there are other
columns also in it.

This query works fine when the myTable1 contains only lesser number of
rows. But, when it contains 2-3 million rows, it takes hell a lot of
time(not over even after 10 minutes). What could be the reason? Is
there something wrong with the Table design? If not, how do I optimize
the query?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 12:18 PM
Rodion.Mironov@gmail.com
 
Posts: n/a
Default Re: Nested query taking long execution time!!!

Hi.

Do you really need all this type convertions (i.e.
SUBSTR(TO_CHAR(ID_TO_NUMBER...) ? What about "CoIA" field type? Why
not to compare "t1.CoIA = t2.CoIA" ?
Is the "CoIA" column a primary key of myTable1 ?

W
On 14 ΖΕΧ, 09:08, qazmlp1...@rediffmail.com wrote:
> select count(distinct t1.ColA)
> from myTable1 t1
> where
> (
> select count( distinct t2.ColB )
> from myTable1 t2
> where SUBSTR(TO_CHAR(ID_TO_NUMBER(t1.ColA)),1,17) =
> SUBSTR(TO_CHAR(ID_TO_NUMBER(t2.ColA)),1,17)
> ) > 1 ;
>
> I need to find the count of the rows in the Table(myTable1) where the
> number of ColB values associated with the ColA value is more than 1.
> myTable contains ColA and ColB as the key columns and there are other
> columns also in it.
>
> This query works fine when the myTable1 contains only lesser number of
> rows. But, when it contains 2-3 million rows, it takes hell a lot of
> time(not over even after 10 minutes). What could be the reason? Is
> there something wrong with the Table design? If not, how do I optimize
> the query?



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 08:15 AM.


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