Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: need help with query
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
![]() |
![]() |