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: Subquery

Re: Subquery

From: Jared Still <jkstill_at_cybcon.com>
Date: Tue, 29 May 2001 12:46:29 -0700
Message-ID: <F001.003129EC.20010529125642@fatcity.com>

Kevin's right of course, try them all, pick the best performing.

Jared

On Tuesday 29 May 2001 13:05, Toepke, Kevin M wrote:
> Jared,
>
> At least with O8i, that's true in about 60-70% of the time. I have found it
> better to use subqueries instead of joins when that's what you mean. In
> some cases the optimizer can eliminate a sort step when using sub-queries
> instead of a join and other times it processes less data.
>
> Sometimes an IN subquery is faster, other times an EXISTS subquery is
> faster. The point is, you have to try the query all 3 ways.
>
> In this case, I suspect that a subquery will be much faster than the join.
> (Because of the rownum = 1 restriction)
>
> Kevin
>
> -----Original Message-----
> Sent: Tuesday, May 29, 2001 3:11 PM
> To: Multiple recipients of list ORACLE-L
>
>
>
> Why change it to subqueries?
>
> The optimizer will just turn it back into a join anyway.
>
> Jared
>
> On Tuesday 29 May 2001 05:15, Roland.Skoldblom_at_ica.se wrote:
> > Hallo you DBAs
> >
> > How can I write this sql query using subqueries?
> >
> > SELECT pbk.nielsenart.varunamn, pbk.nielsenart.strl,
> > pbk.nielsenart.varutxt, null, pbk.nielsenart.vgrp,
> > rik2.hierarki_tekst.tekst, null, pbk.sortiment_vgrp.sortiment,
> > pbk.nielsenart.art_grp, pbk.nielsenart.art_ugrp, null FROM
> > pbk.nielsenart,pbk.sortiment_vgrp,rik2.hierarki_tekst, pbk.rapporttmp
>
> WHERE
>
> > pbk.nielsenart.vgrp=rik2.hierarki_tekst.vgrp
> > AND pbk.sortiment_vgrp.vgrp=pbk.nielsenart.vgrp
> > AND rik2.hierarki_tekst.sett_id=2
> > AND rik2.hierarki_tekst.landkode=46
> > AND pbk.nielsenart.ean=pbk.rapporttmp.EAN
> > AND ROWNUM=1
> >
> >
> > Roland Sköldblom

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jared Still
  INET: jkstill_at_cybcon.com

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: 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 Tue May 29 2001 - 14:46:29 CDT

Original text of this message

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