删除条件和子字符串需要很长时间的querry [英] Delete querry with where condition and substring takes long time

查看:85
本文介绍了删除条件和子字符串需要很长时间的querry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我使用子串删除查询



删除来自[table]的SUBSTRING([field],1,CHARINDEX(N''',[字段]) - 1)= 7



查询循环数百万条记录,并且花费很长时间,调整查询的任何消息,(表格不包含索引或约束)

hi i have delete query using substring

delete From [table] where SUBSTRING([field],1,CHARINDEX(N'''',[field])-1) = 7

the query loops through millions of records,and takes long time,any sugesttion of tuning the query,(the table does not contain indexing or constrains)

推荐答案

您可以根据子串公式创建一个持久计算列,并将该列与数字7进行比较。如果您确定它,我会说它将子串输出的数字转换为int,这将再次使其更快。
You can create a persisted computed column based on the substring formula and compare that column as number 7. I would say if you are sure that it would be number cast the substring output to int, which will again make it faster.


这篇关于删除条件和子字符串需要很长时间的querry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆