Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: sql optimization question

Re: sql optimization question

From: Dave Hau <davehau123_at_netscape.net>
Date: Wed, 27 Aug 2003 12:29:27 -0800
Message-ID: <F001.005CD86B.20030827122927@fatcity.com>


select distinct n.cognateid, m.isirefid,4, linkdate from mt.externallink l, refidmatch m, nametag n where l.objectid = n.geneid
and m.pubmedid = l.identifier
and externaldbid = 9
and l.identifier in
(select identifier from mt.externallink
where externaldbid = 9
group by identifier
having count(distinct objectid) < 6);

HTH,
Dave

gmei_at_incyte.com wrote:
> Hi,
>
> This query took a few minues to return 126K rows (fast):
>
> select distinct n.cognateid, m.isirefid,4, linkdate
> from mt.externallink l, refidmatch m, nametag n
> where l.objectid = n.geneid
> and m.pubmedid = l.identifier
> and externaldbid = 9;
>
> But this query took hours and still no result, I had to kill it:
>
> select distinct n.cognateid, m.isirefid,4, linkdate
> from mt.externallink l, refidmatch m, nametag n
> where l.objectid = n.geneid
> and m.pubmedid = l.identifier
> and externaldbid = 9
> and (select count(distinct objectid) from mt.externallink k
> where k.identifier = l.identifier
> and externaldbid = 9
> and l.objectid !=k.objectid)<5;
>
>
> All the related columns are indexed and table are analyzed. Is there a way
> to re-write the part
>
> select count(distinct objectid) from mt.externallink k
> where k.identifier = l.identifier
> and externaldbid = 9
> and l.objectid !=k.objectid)<5
>
> to make the whole thing faster?
>
> TIA.
>
> Guang
>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Dave Hau
  INET: davehau123_at_netscape.net

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (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).
Received on Wed Aug 27 2003 - 15:29:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US