Friday, March 23, 2012

Is there a better (faster) way?

I am running this query on MS SQL 2000 that is deleting records on an AS400
table. Extremely slow. Is there a different way I should/could do this?
\
Background - Data comes into COMMON. I read the data into #LoadSwipes,
process the data, and then want to delete the processed records from COMMON.
delete KRONOS.RSIGL.TIMECUSTOM.COMMON
from #LoadSwipes ls
inner join KRONOS.RSIGL.TIMECUSTOM.COMMON k
on ls.Area = k.Area and
ls.TimeSt = k.TimeSt and
ls.EmpNum = k.EmpNum and
ls.Clock = k.Clock and
ls.EmpNu9 = k.EmpNu9 and
ls.ActIn = k.ActIn
Thanks
EricHi Eric,
This might not apply to you situation, but one thing that you may consider
is copying the record that you want to keep into a seperate temp table, then
truncate the original table, and finally copy the records from the temp table
back to the original.
This would be useful if the number of records that you want to keep is
dramatically less than the number of records that you want to delete.
--
MG
"Eric Stewart" wrote:
> I am running this query on MS SQL 2000 that is deleting records on an AS400
> table. Extremely slow. Is there a different way I should/could do this?
> \
> Background - Data comes into COMMON. I read the data into #LoadSwipes,
> process the data, and then want to delete the processed records from COMMON.
> delete KRONOS.RSIGL.TIMECUSTOM.COMMON
> from #LoadSwipes ls
> inner join KRONOS.RSIGL.TIMECUSTOM.COMMON k
> on ls.Area = k.Area and
> ls.TimeSt = k.TimeSt and
> ls.EmpNum = k.EmpNum and
> ls.Clock = k.Clock and
> ls.EmpNu9 = k.EmpNu9 and
> ls.ActIn = k.ActIn
>
> Thanks
> Eric
>
>|||Thanks for the suggestion MG. However, I don't think that applies here. The
table on the AS400 is continually receiving data. I read data from that
table into a SQL temp table and process the records in the temp table.
Meantime, more records are flowing into the AS400 table. The temp table
serves as my means of knowing which records can be deleted from the AS400
table.
Eric
"MGeles" <michael.geles@.thomson.com> wrote in message
news:34A0DE2D-FE23-4484-918C-F32E52A09DA6@.microsoft.com...
> Hi Eric,
> This might not apply to you situation, but one thing that you may consider
> is copying the record that you want to keep into a seperate temp table,
then
> truncate the original table, and finally copy the records from the temp
table
> back to the original.
> This would be useful if the number of records that you want to keep is
> dramatically less than the number of records that you want to delete.
> --
> MG
>
> "Eric Stewart" wrote:
> > I am running this query on MS SQL 2000 that is deleting records on an
AS400
> > table. Extremely slow. Is there a different way I should/could do this?
> >
> > \
> >
> > Background - Data comes into COMMON. I read the data into #LoadSwipes,
> > process the data, and then want to delete the processed records from
COMMON.
> >
> > delete KRONOS.RSIGL.TIMECUSTOM.COMMON
> > from #LoadSwipes ls
> > inner join KRONOS.RSIGL.TIMECUSTOM.COMMON k
> > on ls.Area = k.Area and
> > ls.TimeSt = k.TimeSt and
> > ls.EmpNum = k.EmpNum and
> > ls.Clock = k.Clock and
> > ls.EmpNu9 = k.EmpNu9 and
> > ls.ActIn = k.ActIn
> >
> >
> > Thanks
> > Eric
> >
> >
> >

No comments:

Post a Comment