March 16, 2010 at 8:28 am
Hi,
we have a query that copies data from one table to another. Sometimes we copy like 25000 records. This copy is called from the visual basic application. It has a default timeout of 30 seconds. so sometimes it times out. so we are thinking of doing the copy in batches. I looked online to see if I can find any information on how to do it. But I couldn't find any information. can some one help me with this?
Thanks,
sridhar.
March 16, 2010 at 2:12 pm
Only 25,000 rows? (rows... not records) No way should that be taking 30 seconds. Try this.
INSERT INTO TargetTable (column list)
SELECT FROM SourceTable (column list)
WHERE (criteria for rows you want to copy)
Don't bounce result sets from the server to a client application and then back to the server. It is an atrocious waste of time and resources.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 16, 2010 at 3:12 pm
One more side effect of the "bouncing method": sometimes it's done row by row (get one row from the source table and insert it into the target table). That would make things even worse...
March 16, 2010 at 3:28 pm
Hey Lutz 🙂 I beat you to the punch for once !! 😀
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 16, 2010 at 3:34 pm
The Dixie Flatline (3/16/2010)
Hey Lutz 🙂 I beat you to the punch for once !! 😀
You probably benefit from the time zone difference / foreigner issues I suffer...(takes longer to get the data to the server since it has to pass customs/NSA) 😉
March 16, 2010 at 4:22 pm
Hi,
Thanks for the reply. I am not sending the records back to client. It doesn't time out every time. Also the target table has lot of indexes.
Thanks,
sridhar.
March 16, 2010 at 4:29 pm
Sorry, I misunderstood the role of the VB application. Is the visual basic application creating the query string and passing it? Or is it executing a stored procedure that does the copy?
Many indexes create a lot of maintenance overhead. Do you have other transactions inserting/updating/deleting rows at the same time?
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 17, 2010 at 8:51 am
The vb application just calls the stored procedure. The stored procedure does the copy of records. As of now it is the only stored procedure that inserts data into the table.
March 17, 2010 at 11:19 am
Would it be possible for you to post the procedure?
Mabe we can help to speed it up a little bit.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply