RE: SQL statement performance

2001-05-15 Thread Daemen, Remco

Hi Guang,

Try something like this:

select distinct(spid) spid,name,commonname 
from
(
select distinct(spid) spid,name,commonname 
from   results a
,  species
where  a.queryspid = species.id
union all
select distinct(spid) spid,name,commonname 
from   results b
,  species
where  a.subjspid = species.id
);

HTH,  Remco

-Oorspronkelijk bericht-
Van: Guang Mei [mailto:[EMAIL PROTECTED]]
Verzonden: dinsdag 15 mei 2001 1:20
Aan: Multiple recipients of list ORACLE-L
Onderwerp: SQL statement performance


Oracle : 8.0.5
Platform : Sun

SQL statement:

select distinct(spid) spid, name, commonname from (
select distinct queryspid spid from results union
select distinct subjspid  spid from results
   ) a, species
   where a.spid=species.id ;

Table Species only has 33 records, while table results has about 800

records. There are indexes on queryspid and subjspid.

This query is somehow slow. Is there any easy way to speed it up?

Thanks.
_
Get your FREE download of MSN Explorer at http://explorer.msn.com

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Guang Mei
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Daemen, Remco
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



RE: SQL statement performance

2001-05-15 Thread Toepke, Kevin M

Here's another version of the query that has only 1 sort. 

SELECT a.spid, s.name, s.commonname
FROM   (SELECT /+* NO_MERGE(b) */ DISTINCT spid
FROM   (SELECT r.queryspid  AS spid
FROM   results  r
  ,species  s
WHERE  r.subjspid  = s.id
UNION ALL
SELECT r.subjspid
FROM   results  r
  ,species  s
WHERE  r.subjspid != r.queryspid
ANDr.subjspid  = s.id) b
   ) a
  ,specias  s
WHERE  a.spid = s.id;

Kevin
-Original Message-
Sent: Tuesday, May 15, 2001 6:31 AM
To: Multiple recipients of list ORACLE-L


Hi Guang,

Try something like this:

select distinct(spid) spid,name,commonname 
from
(
select distinct(spid) spid,name,commonname 
from   results a
,  species
where  a.queryspid = species.id
union all
select distinct(spid) spid,name,commonname 
from   results b
,  species
where  a.subjspid = species.id
);

HTH,  Remco

-Oorspronkelijk bericht-
Van: Guang Mei [mailto:[EMAIL PROTECTED]]
Verzonden: dinsdag 15 mei 2001 1:20
Aan: Multiple recipients of list ORACLE-L
Onderwerp: SQL statement performance


Oracle : 8.0.5
Platform : Sun

SQL statement:

select distinct(spid) spid, name, commonname from (
select distinct queryspid spid from results union
select distinct subjspid  spid from results
   ) a, species
   where a.spid=species.id ;

Table Species only has 33 records, while table results has about 800

records. There are indexes on queryspid and subjspid.

This query is somehow slow. Is there any easy way to speed it up?

Thanks.
_
Get your FREE download of MSN Explorer at http://explorer.msn.com

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Guang Mei
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Daemen, Remco
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Toepke, Kevin M
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



SQL statement performance

2001-05-14 Thread Guang Mei

Oracle : 8.0.5
Platform : Sun

SQL statement:

select distinct(spid) spid, name, commonname from (
select distinct queryspid spid from results union
select distinct subjspid  spid from results
   ) a, species
   where a.spid=species.id ;

Table Species only has 33 records, while table results has about 800 
records. There are indexes on queryspid and subjspid.

This query is somehow slow. Is there any easy way to speed it up?

Thanks.
_
Get your FREE download of MSN Explorer at http://explorer.msn.com

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Guang Mei
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).