Home » SQL & PL/SQL » SQL & PL/SQL » Problem with a select distinct (Oracle 9i)
Problem with a select distinct [message #427452] |
Thu, 22 October 2009 12:43 |
Nau
Messages: 24 Registered: October 2004
|
Junior Member |
|
|
I have a problem with a select distinct, I have the next sql:
select distinct a,b,c,d from (select a,b,c,d,e,f...from table where ...)
The subselect have 25000 rows, it last about 10 seconds, but the select distinct over the subselect takes a long time..., I have waited for 20 minutes, and finally canceled the sql.
When I make this alternative path:
create table2 as (select a,b,c,d,e,f...from table where ...)
select distinct a,b,c,d from table2
The distinct finish in 5 seconds.
I don't understand the differences.... I can't do the alternative path, I need the first sql to work.
I don''t know where is the problem
Any advice will be greatly appreciatted
|
|
|
|
|
Re: Problem with a select distinct [message #427466 is a reply to message #427452] |
Thu, 22 October 2009 14:02 |
Its_me_ved
Messages: 979 Registered: October 2009 Location: India
|
Senior Member |
|
|
This is your 22nd post.You should know how to put your question.
[code]
select distinct a,b,c,d from (select a,b,c,d,e,f...from table where ...)[code]
Why you need another level of sub select when u can do like this
select distinct a,b,c,d...from table where ...
|
|
|
|
Re: Problem with a select distinct [message #427509 is a reply to message #427452] |
Fri, 23 October 2009 00:20 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Nau wrote on Thu, 22 October 2009 19:43I have a problem with a select distinct, I have the next sql:
select distinct a,b,c,d from (select a,b,c,d,e,f...from table where ...)
The subselect have 25000 rows, it last about 10 seconds, but the select distinct over the subselect takes a long time..., I have waited for 20 minutes, and finally canceled the sql.
Did it take 10 seconds to retrieve ALL rows, or did you only saw a subset of it (if you are using TOAD, PL/SQL Developer or SQL Developer, it is the latter).
|
|
|
Goto Forum:
Current Time: Thu Dec 05 01:10:53 CST 2024
|