Home » SQL & PL/SQL » SQL & PL/SQL » optimizing sql statement
optimizing sql statement [message #21652] Wed, 21 August 2002 13:07 Go to next message
Son Nguyen
Messages: 8
Registered: July 2002
Junior Member
Hello,

The Part table in this query has 15 MILLION items, and this query takes FOREVER to run. Is there a BETTER way to write this query? In SQL server I was able to use right joins, etc and it worked faster. But with oracle I do not have that luxary.

Thanks.

SQL STATEMENT:
UPDATE Part SET (Part.MfrName, Part.MfrPartNum) = (SELECT @C2A_CAT.MfrName, @C2A_CAT.MfrPartNum WHERE Part.PartID = @C2A_CAT.PartID) WHERE (PART.PartNum, PART.PartNumExt, PART.UOM) IN (SELECT PartNum, PartNumExt, UOM FROM @C2A_CAT)
Re: optimizing sql statement [message #21658 is a reply to message #21652] Wed, 21 August 2002 14:11 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
We can only help you if you provide the exact query - this example has numerous syntax errors.
Re: optimizing sql statement [message #21662 is a reply to message #21658] Wed, 21 August 2002 15:02 Go to previous message
Son Nguyen
Messages: 8
Registered: July 2002
Junior Member
I don't see the syntax in the other sql statement but here is a simple one that does the same thing. I tested it and it works so the syntax is correct. Here is the underlaying problem... I have table A with 5 records, table B with 2 records.... if I run that query WITHOUT the very last WHERE clause it will update 5 records. I need to put in that last where clause so it will only update the records where it MATCHES, or else it sets the rest to NULL. This query takes forever to run, is there a better way to accomplish the same solution?

SQL STATEMENT:
update a set a.description = (select b.description from b where a.partnum = b.partnum)
where a.partnum in (select partnum from b);
Previous Topic: Prompting User For Values
Next Topic: can't install oracle 8i on 2000 o/s
Goto Forum:
  


Current Time: Fri Apr 19 17:10:38 CDT 2024