dbTalk Databases Forums  

Slow Query

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Slow Query in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joe
 
Posts: n/a

Default Slow Query - 09-13-2004 , 01:28 PM






Howdy,
First of all thanks in advance,
I'm runnig SQL 2000 from my desktop
I've created a table that I use for reporting purposes sysfact_temp.
This table is created via a series of SQL statements. Once created,
there are around 15000 rows and 20 fields.
The second ].[dbo].[CXMSShip_Fact View] has aprox 30000 rows

I have tried to run this query as a task in a DTS package and I
noticed that it takes hours to perform the step with the query posted
below.
Also I've tried to write the query in different ways but still take
too long to run.
Apparently it goes row by row trying to find a match.....

Any help on how to improve the performance of this query would be
greatly appreciated
Thanks in advacance

Joe.


UPDATE Sysfact_temp
SET Total_Qty = (SELECT SUM( a.TRQty )
FROM [CS_Analysis].[dbo].[CXMSShip_Fact View]
AS a
WHERE a.Rack = Sysfact_temp.salesorder
and SysFact_temp.complete_count = '1'
Group by a.Rack)

Reply With Quote
  #2  
Old   
Jéjé
 
Posts: n/a

Default Re: Slow Query - 09-13-2004 , 06:29 PM






1. insure you have no indexes on the updated column.
2. update the statistics of your tables before using these tables (update
statistics mytable with fullscan)

Try this query:

UPDATE Sysfact_temp
SET Total_Qty = SumTRQY
from
(SELECT Rack, SUM( TRQty ) as SumTRQY
FROM [CS_Analysis].[dbo].[CXMSShip_Fact View]
Group by Rack
) A
where
a.Rack = Sysfact_temp.salesorder
and SysFact_temp.complete_count = '1'


"Joe" <desechable1 (AT) yahoo (DOT) com> a écrit dans le message de news:
83fd96b2.0409131028.6aa4672a (AT) po...OT) google.com...
Quote:
Howdy,
First of all thanks in advance,
I'm runnig SQL 2000 from my desktop
I've created a table that I use for reporting purposes sysfact_temp.
This table is created via a series of SQL statements. Once created,
there are around 15000 rows and 20 fields.
The second ].[dbo].[CXMSShip_Fact View] has aprox 30000 rows

I have tried to run this query as a task in a DTS package and I
noticed that it takes hours to perform the step with the query posted
below.
Also I've tried to write the query in different ways but still take
too long to run.
Apparently it goes row by row trying to find a match.....

Any help on how to improve the performance of this query would be
greatly appreciated
Thanks in advacance

Joe.


UPDATE Sysfact_temp
SET Total_Qty = (SELECT SUM( a.TRQty )
FROM [CS_Analysis].[dbo].[CXMSShip_Fact View]
AS a
WHERE a.Rack = Sysfact_temp.salesorder
and SysFact_temp.complete_count = '1'
Group by a.Rack)



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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.