一个有关between and更更新的奇怪问题
SEQUENCE int identity PK字段
manufacturerId int
SupplierId int
OENbr varchar(50)
PartsDataSupplierArticleNumber varchar(50)
canDel bit
dupCount int
minSEQ int 用于存储重复值里面最少的SEQUENCE值(manufacturerId,SupplierId,OENbr,PartsDataSupplierArticleNumber这4个值都相同即为重复)
对manufacturerId,SupplierId,OENbr,PartsDataSupplierArticleNumber这4个字段进行了非聚集索引
现在是想要把重复值删除,现执行以下更新语句:
declare @s datetime,@e datetime
set @s = getdate()
declare @current int,@end int
set @current = 100000000
set @end = 100010000
update a set
minSEQ=
(
select min(SEQUENCE) from article_cross where manufacturerId=a.manufacturerId and OENbr=a.OENbr and SupplierId=a.SupplierId and PartsDataSupplierArticleNumber=a.PartsDataSupplierArticleNumber
)
from article_cross a
where
a.SEQUENCE between @current and @end
set @e = getdate()
select datediff(ms,@s,@e)
这里耗时六十多秒,如果将between and 直接改成常数a.SEQUENCE between 100000000 and 100010000,则只需零点几秒,不知道sqlserver把时间花在哪里了。
没办法,数据量太大,直接用一条语句删除的话,一般运行几个小时后报错,以及日志巨大,磁盘空间不够等等问题,现d只能分步来进行操作,谁知又遇到这个奇怪的问题。
相关推荐
一个奇怪的问题使用ajax提交必须alert才能赋值
在使用ajax提交的时候将返回值赋给一个变量,无论怎么写都没法赋值,刚开始怀疑js有错但是ie没有反应过来,多次清缓存、部程序都没效果
DB2 V11.1下载安装与SQL between and边界实战指南
数据库是企业数据架构的核心,SQL查询的边界条件直接影响结果的正确性。BETWEEN AND作为常用的范围过滤语法,其包含边界值的特性常被开发者误解,尤其在处理日期时间字段时容易因隐含的零点转换产生数据遗漏。理解其原理、掌握替代写法,并配合索引优化,能显著提升查询准确性与性能。在企业级数据库环境中,稳定可靠的版本部署是保障业务连续性的基础,而DB2 V11.1凭借其成熟的稳定性和对OLAP场景的优化,仍在许多关键行业生产系统中广泛运行。从Linux环境下的静默安装、实例配置,到建库建表与SQL实战,再到端口
SQL Server上的一个奇怪的Deadlock及其分析方法
SQL Server上的一个奇怪的Deadlock及其分析方法
奇怪的小球
原创作品,创新的一款游戏,同时也是一个关于线程的作品,具有开发价值。
牛客 – 奇怪的背包问题增加了(贪心)
题目链接:点击查看 题目大意:中文题意 题目分析: 代码: #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned long long ull; const int inf=0x3f3f3f3f; const int N=1e5+100; struct Node { int val,id;


