Salve,
vorrei un consiglio da parte vostra, ho una procedura di importazione dati, che legge i dati da una tabella di un db e li inserisce in un altro db. Il mio problema è la velocità di esecuzione troppo ampio vorrei se possibile ottimiizzarlo, di seguito posto il codice e vorrei sapere cosa ne pensate.
Allo stato attuale impiega 35 minuti per l'importazione di 3000 record
Grazie anticipatamente
<%
Set tabcon2 = Server.CreateObject("ADODB.Connection")
tabcon2.Open "Driver={MySql ODBC 3.51 Driver};Server=localhost;Port=3306;Option=131072;S tmt=;uid=root;pwd=;database=db1"
Set tabcon = Server.CreateObject("ADODB.Connection")
tabcon.Open "Driver={MySql ODBC 3.51 Driver};Server=localhost;Port=3306;Option=131072;S tmt=;uid=root;pwd=;database=db2"
' creo il recordset dela tabella del primo db circa 44.000 record
Set tabRs = Server.CreateObject("ADODB.Recordset")
strSQL="SELECT * FROM rassegna order by DATA desc "
tabRs.Open StrSQL, tabcon2
if not tabRs.eof then
do while not tabRs.eof
data = tabRs("DATA")
datatemp=split(data,"/")
data=datatemp(2)&"-"&datatemp(1)&"-"&datatemp(0)
sezione = 3
StrSQL="INSERT INTO informazioni (IDTESTATA,DATAInformazione, PAROLECHIAVE, TITOLO,TITOLO1, TESTO, AUTORE,VERIFICATO, FK_REGIONE, TIPOSEZIONE, AREANAZIONALE , id ) VALUES (" & tabRs("IDTESTATA") &", '"&data&"', '"&tabRs("PAROLECHIAVE")&"', '"&tabRs("TITOLOBREVE")&"', '"&tabRs("TITOLO")&"', '"&tabRs("testo")&"', '"&tabRs("AUTORE")&"','"&tabRs("VERIFICATO")&"' , '"&tabRs("FK_REGIONE")&"',"&sezione&", 'Vero',"& tabRs("Id")&" )"
tabcon.execute(StrSQL)
' Prendo l'id dell'ultimo record inserito"
set objRs = Server.createObject("ADODB.recordset")
objRs.open strsql, tabcon, 1, 3
if not objRs.eof then
idrecordinserito = objRs(0)
end if
objRs.Close
set objRs = nothing
strSQLIns="insert into congsezareetem (idarea, idInfo)VALUES ("&tabRs("idarea")&","&idrecordinserito&" )"
tabcon.execute(strSQLIns)
tabRs.movenext
loop
end if
tabcon2.close
set tabcon2 = nothing
tabcon.close
set tabcon = nothing
%>
![]()