日期:2014-05-18  浏览次数:20496 次

求助一句Delete语句的问题
delete   item   where   id   not   in(select   max(id)   from   item   group   by   cast(link   as   varchar(8000)))
这句是我的语句,可是item表数据量很大后查询速度就很慢,item表有6万条数据,执行完这句要40秒。

然后我就
delete   item   where   id   not   in(select   max(id)   from   item   group   by   cast(link   as   varchar(8000)))   and   DATEDIFF(day,datetime,getdate())=0
这句目的就是想删除今天重复的数据,可是还是很慢,请问有什么办法可以变快吗?谢谢!

------解决方案--------------------
up
------解决方案--------------------
--try
delete item where id not in (select max(id) from item group by link) and DATEDIFF(day,datetime,getdate())=0

--try
delete item where id not in (select max(id) from item where DATEDIFF(day,datetime,getdate())=0 group by link) and DATEDIFF(day,datetime,getdate())=0