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: NOT IN performance problem

Re: NOT IN performance problem

From: Abul Fazal <angmokios_at_yahoo.com>
Date: Tue, 16 Jul 2002 06:13:24 -0800
Message-ID: <F001.0049903E.20020716061324@fatcity.com>


Select personid from person
minus
select personid from phonenumber

Fazal
--- "Dennis M. Heisler" <dheisler_at_binghamton.edu> wrote:
> select personid from person
> where not exists (select '1' from phonenumber
> where personid = person.personid);
>
> Nils Höglund wrote:
> >
> > Hello,
> >
> > I have encountered a performance problem. I use
> "Oracle8 Enterprise Edition
> > Release 8.0.5.0.0 - Production."
> >
> > I have two tables. "phonenumber" and "person",
> each person has none, one or
> > many phonenumbers referenced to him.
> >
> > The phonenumber-table is structured like:
> > phonenumber.personid
> > phonenumber.phonenumber
> >
> > The person-table is structured like:
> > person.personid
> > person.name
> > person.address
> >
> > I wan't to know which persons that does NOT have
> any phonenumber(s).
> >
> > I can write the query as:
> > SELECT personid FROM phonenumber WHERE personid
> NOT IN (
> > SELECT personid FROM person);
> >
> > However, since my tables are quite large, it takes
> forever to run my query.
> > In the real database both (or
> > atleast one) of "person" or "phonenumber" are
> views.
> >
> > To figure out who _does_ have phonenumbers is
> SIGNIFICANTLY faster.
> > (SELECT DISTINCT person.personid FROM person,
> phonenumber WHERE
> > person.personid=phonenumber.personid)
> >
> > I'm wondering how I could restructure or rewrite
> my query ("who doesn't have
> > any phoinenumbers?") to run faster,
> > or if there is anything else I can do to optimize
> the query?
> >
> > Any suggestions?
> >
> > --
> > /Nils Höglund, Naqua KB
> >
> > E-mail: nils_at_naqua.se
> > Web: http://www.naqua.se/
> > Home Phone: +46 (0)18 30 09 19
> > Cellular Phone: +46 (0)736 51 74 58
> > Address: Nya Valsätrav. 26 B
> > SE-756 46
> > Uppsala, Sweden
> > --
> > Please see the official ORACLE-L FAQ:
> http://www.orafaq.com
> > --
> > Author: =?iso-8859-1?Q?Nils_H=F6glund?=
> > INET: nils_at_naqua.se
> >
> > 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).
> --
> Please see the official ORACLE-L FAQ:
> http://www.orafaq.com
> --
> Author: Dennis M. Heisler
> INET: dheisler_at_binghamton.edu
>
> 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).


Abul Fazal
Production Support Services - Quantum Leap Standard Charted Bank
Singapore
HP : 65-94887900

Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Abul Fazal
  INET: angmokios_at_yahoo.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 Jul 16 2002 - 09:13:24 CDT

Original text of this message

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