Very slow after applying sp3!
Dear Andrew
Thanks for the response.
I tried generating the execution plan but failed to do so because the
SQL2000 optimizer refuses to generate execution plan when it encounters a
temp table. I may be wrong, anyone could offer some suggestion to generate
the execution plan for code using temp table ??
Anyway, I went a step further by diagnosting the store procedure.
Interestingly this is what I found out.
For the same machine running SQL 2000 with sp2, execution of the following
code was excellent, very fast... took me about 15 minute to generate a
monthly report. However, after applying sp3, the CPU usage spike irregulary
and it took longer than 5 hours to complete the same job.
SELECT a.shipment_profile_id,
a.scan_type_c,
a.scan_exception_c,
a.scan_dt,
a.track_loc_c
INTO #asia_new_tb FROM scan a
WHERE EXIST ..condition1
and condition2
and condition3
...
..
...
DECLARE asia_new CURSOR for
SELECT shipment_profile_id,
scan_type_c,
scan_exception_c,
scan_dt,
track_loc_c
FROM #asia_new_tb
OPEN asia_new
FETCH asia_new into @shipment_id,
@scan_type,
@scan_exce,
@scan_dt,
@track_loc
CLOSE asia_new
DEALLOCATE asia_new
DELETE #asia_new_tb
All I did was ...made minor modification to the above code by declaring the
cursor to a user table instead of the temp table. So the code looks like the
following (running in a machine with SQL 2000 and sp3).
The execution of this code by SQL2000 with sp 2 was extreme slow. However,
it works extremely well in SQL2000 with sp3.
Appreciate you or other can help to verify this and even perhaps find an
explanation for this.
DECLARE asia_new CURSOR for
select a.shipment_profile_id,
a.scan_type_c,
a.scan_exception_c,
a.scan_dt,
a.track_loc_c
FROM scan a
WHERE EXIST..condition1
AND condition2
AND condition3
OPEN asia_new
FETCH asia_new INTO @shipment_id,
@scan_type,
@scan_exce,
@scan_dt,
@track_loc
CLOSE asia_new
DEALLOCATE asia_new
DELETE #asia_new_tb
|