我有一个包含一些信息和字符串 ID 的表(Table1)
我有另一个表(表 2),其中包含更多信息和类似的字符串 ID(中间缺少一个额外的字符)。
我最初是在
t2.StringID = substring(t1.StringID,0,2)+substring(t1.StringID,4,7)
但这太慢了,所以我决定在 Table1 上创建一个新列,该列已经映射到 Table2 的 PrimaryID,然后索引该列。
因此,要更新该新列,我这样做:
select distinct PrimaryID,
substring(t2.StringID,0,2)+
substring(t2.StringID,4,7)) as StringIDFixed
into #temp
from Table2 t2
update Table1 tl
set t1.T2PrimaryID = isnull(t.PrimaryID, 0)
from Table1 t11, #temp t
where t11.StringID = t.StringIDFixed
and t1.T2PrimaryID is null
它在几秒钟内创建了临时表,但更新已经运行了 25 分钟,我不知道它是否会完成。
表1有45MM行,表2有1.5MM
我知道这是大量的数据,但我仍然觉得这不应该那么难。
这是 Sybase IQ 12.7
有任何想法吗?
谢谢。