求助一句Delete语句的问题

HarleyTung 2007-09-20 07:38:39
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
这句目的就是想删除今天重复的数据,可是还是很慢,请问有什么办法可以变快吗?谢谢!
...全文
122 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
HarleyTung 2007-09-20
  • 打赏
  • 举报
回复
非常感谢,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
1秒都不到。呵呵
Limpire 2007-09-20
  • 打赏
  • 举报
回复
--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
HarleyTung 2007-09-20
  • 打赏
  • 举报
回复
求助,谢谢!
火星求索 2007-09-20
  • 打赏
  • 举报
回复
up

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧