sql语句 不影响执行效果的前提下,提高执行效率。用索引等等方法。谢谢!
时间:2011-12-02
来源:互联网
程序介绍:两张表a,b合成一张表ae:a表两列(OrderID(编号),jgz(甲骨字))6155行。b表(OrderID(编号),yw(一段甲骨字))45515行,yw(一段甲骨字)里的有a表中的甲骨字构成。
ae(记录编号(一段甲骨字的编号),编号(甲骨字编号),次数 (一段甲骨字中每个甲骨字出现的次数))
目的:提高算法执行效率。45515条记录,我执行的半个多小时。谢谢!!!
create table ae
( 记录编号 int,
编号 int not null,
次数 int
)
declare @i1 int,@c1 nvarchar(MAX), @i int,@c nvarchar(1),@c3 int
set @i1=1
while @i1<45515
begin
set @c1=
(select yw from b where OrderID=@i1)
select @i=1
while @i <=len(@c1)
begin
select @c=substring(@c1,@i,1),@i=@i+1
set @c3=
(select OrderID from a where jgz=@c)
update ac set 次数=次数+1 where 编号=@c3 and 记录编号=@i1
if @@rowcount=0
insert into ac (记录编号,编号,次数) values(@i1,@c3,1)
end
set @i1=@i1+1
end
ae(记录编号(一段甲骨字的编号),编号(甲骨字编号),次数 (一段甲骨字中每个甲骨字出现的次数))
目的:提高算法执行效率。45515条记录,我执行的半个多小时。谢谢!!!
create table ae
( 记录编号 int,
编号 int not null,
次数 int
)
declare @i1 int,@c1 nvarchar(MAX), @i int,@c nvarchar(1),@c3 int
set @i1=1
while @i1<45515
begin
set @c1=
(select yw from b where OrderID=@i1)
select @i=1
while @i <=len(@c1)
begin
select @c=substring(@c1,@i,1),@i=@i+1
set @c3=
(select OrderID from a where jgz=@c)
update ac set 次数=次数+1 where 编号=@c3 and 记录编号=@i1
if @@rowcount=0
insert into ac (记录编号,编号,次数) values(@i1,@c3,1)
end
set @i1=@i1+1
end
作者: banmuhuatian 发布时间: 2011-12-02
能不能直接用判断条件更新,而不是写这么多的循环。
作者: AcHerat 发布时间: 2011-12-02
全部是循环 效率不会高的。
作者: fredrickhu 发布时间: 2011-12-02
用游标试试
作者: ssp2009 发布时间: 2011-12-02
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28