【发布时间】:2012-05-13 23:33:16
【问题描述】:
我有一个函数,它接受两个分隔字符串并返回公共元素的数量。
函数的主要代码是(@intCount是预期的返回值)
SET @commonCount = (select count(*) from (
select token from dbo.splitString(@userKeywords, ';')
intersect
select token from dbo.splitString(@itemKeywords, ';')) as total)
其中 splitString 使用 while 循环和 charIndex 将字符串拆分为分隔标记并将其插入到表中。
我遇到的问题是,这仅以每秒约 100 行的速度处理,并且根据我的数据集的大小,这将需要大约 8-10 天才能完成。
两个字符串的长度最多可达 1500 个字符。
有没有我能以足够快的速度达到这个速度以供使用?
【问题讨论】:
-
这是你需要一直运行的东西,还是一次性的?
-
我正在运行一些数据挖掘模拟,所以每当我的模型发生变化或我想尝试新的公式时都需要这样做。可能不是很频繁
标签: sql optimization sql-server-2008-r2