SQL2000批量入库的性能
以下是一个采集入库的过程
1-记录新闻到表news
2-记录标签到表tag
3-记录新闻和标签的对应关系到tags
现在的效率很差,请教高手有什么优化方法来提高效率。什么方法都行。
Sub NewsToDate(url,tit,jians)
'1--插入News表并判断是否有此记录
set rs= Server.CreateObject("adodb.recordset")
sql="select * from kw_news where url='"&url&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.addnew
rs("title")=tit
if sets(1)=1 then rs("tittop")=getrnd(tit)
rs("content")=""
rs("jians")=jians
rs("url")=url
rs("state")=0
rs.update
id=rs("id")
end if
rs.close
set rs=nothing
if id>0 then
tag=getXmlDom(tit)
tag=replace(tag," ","")
tag=split(tag,",")
tag1=tag(1)
for i=0 to ubound(tag)
if tag(i)<>"" then
'2--插入到Tag表并判断有无重复
set rs= Server.CreateObject("adodb.recordset")
rs.CursorLocation = 3
sql="select * from kw_tag where tagname='"&tag(i)&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
rs.addnew
rs("tagname")=tag(i)
rs.update
end if
tmp=tmp&","&rs("id")
rs.close
set rs=nothing
end if
next
tmp=split(tmp,",")
for i=0 to ubound(tmp)
if tmp(i)<>"" then
'2--把对应关系记录到Tags
set rs= Server.CreateObject("adodb.recordset")
sql="select * from kw_tags"
rs.open sql,conn,1,3
rs.addnew
rs("stype")=1
rs("tagid")=tmp(i)
rs("useid")=id
rs.update
rs.close
set rs=nothing
end if
next
end if
end if
End Sub