Unix Technical Forum

Using *not in* clause in an "Update .......++ sub Query"

This is a discussion on Using *not in* clause in an "Update .......++ sub Query" within the Sybase forums, part of the Database Server Software category; --> Hi All, I've an update statement which includes a sub-query. On top of this I use *not in* clause. ...


Go Back   Unix Technical Forum > Database Server Software > Sybase

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 03:23 PM
Vamshi
 
Posts: n/a
Default Using *not in* clause in an "Update .......++ sub Query"

Hi All,
I've an update statement which includes a sub-query. On top of this I
use *not in* clause. Well, when the update statement is run it goes on
forever.
Here is the SQL statement:
--------------------BGN----------------------
-- Should update around 4200 rows
UPDATE T1
SET T1.C01 = '12/31/2008'
WHERE T1.C01 IS NULL
AND T1.C02 = 333
AND T1.C03 NOT IN
-- Returns around 4000 rows
(SELECT convert(varchar,T2.C01)
FROM T2
WHERE T2.C02 = '01/01/2003'
AND T2.C03 IS NULL)
--------------------END----------------------

As described int the above SQL the number of rows returned by inner
query is around 4000 and the outer update statement should update
around 4200 rows. PLUS I'm forced to use "convert" function as the
fields the exist on either side of *not in* are odifferent type.

I've tried using Indexes in the sub-query,but it's of not much use.

Any ideas?

Cheers,
Gurram
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 03:23 PM
Ed Avis
 
Posts: n/a
Default Re: Using *not in* clause in an "Update .......++ sub Query"

yrg01@yahoo.com (Vamshi) writes:

>I've an update statement which includes a sub-query. On top of this I
>use *not in* clause. Well, when the update statement is run it goes
>on forever.


Try it with 'set rowcount 1' and see if even that takes forever. Try
'set showplan on' to see what it is doing. If you remove the 'not in'
subquery does your update go faster?

--
Ed Avis <ed@membled.com>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:17 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com