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

Home -> Community -> Usenet -> c.d.o.tools -> Re: need help with query

Re: need help with query

From: Bob Morrison <rmorrison_at_cahners.com>
Date: 1997/07/15
Message-ID: <33CBEF55.5341@cahners.com>#1/1

Lisa M. Lewis wrote:
>
> Can anyone tell me if there is a better way to perform this update:
>
> UPDATE users u
> SET u.usermapid = ( SELECT ncm.usermapid
> FROM NewCookieMap ncm
> WHERE ncm.cookie = u.cookie )
> WHERE EXISTS ( SELECT 'x'
> FROM NewCookieMap ncm
> WHERE ncm.cookie = u.cookie );
>
> This query is in intended to update several million records.
>
> It takes forever -- I don't know how long yet because it is still
> running.
>
> Note: this query is inside a stored procedure.
>
> Thanks in advance!
>
> Lisa
>
> P.S. Please reply by e-mail

Try using:

UPDATE users u
SET u.usermapid = ( SELECT ncm.usermapid

                                   FROM NewCookieMap ncm
                                   WHERE ncm.cookie = u.cookie )
 WHERE u.cookie in (select ncm.cookie 
                   FROM NewCookieMap ncm);

This assumes that there is an index on users(cookie) and an index on NewCookieMap(cookie).

Bob Morrison Received on Tue Jul 15 1997 - 00:00:00 CDT

Original text of this message

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