August 5, 2005 at 7:29 am
Here's a simple question .......
If I run this script in query analyzer, do the statements execute in order (serially), or is it possible they are executing in parallel ?
Insert into TableA1 Select * from TableA
Insert into TableB1 Select * from TableB
Insert into TableC1 Select * from TableC
August 5, 2005 at 7:32 am
I'd assume serially but then again I know squat about parallelism. So I'll see if others can confirm this.
August 5, 2005 at 7:38 am
I did something similar in QA and the execution plan shows the inserts (seemingly) being done serially! but then again I've never seen what a parallel query execution plan looks like and how this can be confirmed...maybe another noeld question...???????
**ASCII stupid question, get a stupid ANSI !!!**
August 5, 2005 at 7:47 am
Even though the SQL Server engine might use parallellism to execute a query quicker (though highly unlikely with these queries), it does not mean that the clients suddenly become asynchronous. So the queries are definitely executed in serial, with the first one ending (and returning results) before the second one starts. (QA however does not show the results until all the queries are finished, but that's something else)
August 5, 2005 at 7:50 am
or maybe a chris hedgate question...
**ASCII stupid question, get a stupid ANSI !!!**
August 5, 2005 at 8:12 am
An "anyone-of-a-lot-of-possible-persons" question.
August 5, 2005 at 8:58 am
The reason I ask is that I was copying data from a bunch of tables in one DB to another DB. Some of the tables had relationships to each other, so that data in TableB could not be inserted unless there was related data in TableA. My insert script took this into account so I had the insert scripts in the right order.
I ran my script one day, and it worked fine, and then the next day, I truncated the data and ran it again, but got errors this time. My source data hadn't changed, and my insert script hadn't changed. That made me wonder if the actual insert statements were happening in slightly different sequences from one time to the next.
August 5, 2005 at 9:05 am
Well sometime changed because that fails now... What's the error?
August 5, 2005 at 9:19 am
By "the next day, I truncated the data and ran it again", do you actually mean you ran TRUNCATE? If you have foreign keys on the table you cannot run TRUNCATE, so that might be the error. Or even that you did not see the errors for tuncate, and then you got a primary key violation when running the insert script.
August 6, 2005 at 9:44 pm
Sorry ........ I "deleted" the data, not truncated
August 7, 2005 at 3:35 am
Ok, so the truncate problems are out of the question then. What was the error message that you got?
August 8, 2005 at 8:38 pm
what you want should be better accomplished by using DTS if it's not a one off thing. Using it you can do several tasks in parallel or sequence them.
However if you put the statements in a single stored procedure or script in query analyzer, they will be executed sequentially.
For foreign key relationships in a batch job, if the data volume is large, you might want to drop the foreign key constraints and any indexes in the target tables to speed up the inserts, can make a huge difference.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply