PDA

View Full Version : diff between addnew and sql insert statement


zkkee
10-19-02, 05:21
hi all...

this happen in VB 6

I tried to create a new record (oracle) by using SQL insert statement and .addnew/update method and found that SQL insert is much faster than .addnew/update mtd. Anybody know why ? If the table size is very big....is it better to use SQL insert than .addnew/update ?

rnealejr
10-19-02, 14:09
The short answer is that it is always faster to do a direct sql statement over the addnew/update. Depending on the cursor and other properties, ado has to manage quite a bit when using the addnew/update. When dealing with open recordsets using the addnew method, ado has to manage whether a current record was being edited and if so it call update - and when you use addnew, ado caches the changes locally then on update posts the changes to the database and changes properties for the recordset object ... so there is much more going on behind the scenes than just a straight sql statement that returns a closed recordset object. Use the connection's execute method for non-row returning sql commands - such as insert/update/delete.

zkkee
10-20-02, 02:01
thanks rnealejr.....got it :) i like this wensite so much.....fast response...

rnealejr
10-20-02, 20:48
Happy to help.

ktran2001
10-25-07, 11:48
Here is my code:

set rs = server.CreateObject("adodb.recordset"
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open "tblClaimHistory", cnn, , , adCmdTable
lngOffset = 0
Do While lngOffset < lngFileSize
varChunk = leftB(RightB(varFDFContent, lngFileSize - lngOffset), iChunkSize)
rs.Fields("ClaimContent").AppendChunk varChunk
lngOffset = lngOffset + iChunkSize
Loop
rs.Update
rs.Close
set rs = nothing

----
I got timeout expired, and need to make this update goes faster.

So how do you replace:

rs.Fields("ClaimContent").AppendChunk varChunk

with update query?

Thanks.