sql server merge into 与update 批量更新1 百万测试数据的性能比较
1. 1百万的测试数据的生成
declare @index int;
begin
set @index=0;
while @index<1000000
begin
insert into teptable values(@index,STR(@index)+'name',str(@index)+'appname');
set @index=@index+1;
end
end
2. merge into sql 更新语句
-- 同库数据更新
merge into teptable1 as t1
using teptable1 as t2
on t1.id=t2.id
when matched then
update set t1.name=t2.appname
when not matched then
insert
values (t2.id,t2.name,t2.appname);
-- 跨库数据更新
merge into buckinsert.dbo.teptable1 as t1
using userinfo.dbo.teptable as t2
on t1.id=t2.id
when matched then
update set t1.appname=t2.appname+'demo aaa'
when not matched then
insert
values (t2.id,t2.name,t2.appname);
以上sql 分为跨库与同库之分
3. update 批量语句 sql
update a set name = b.appname+'ssss' from teptable1 a,teptable1 b
where a.id =b.id
4. 生成的执行任务的截图
a. 使用update 的任务截图
b. merge into 的任务截图 跨库
5. 以上为测试以及sql 任务执行的图形,从中我们可以比较出一些性能上的差异
具体的一些显示的一些术语大家可以去网上搜索。
同时附上同库的任务截图
接上图
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)