Hi All.
I am having an issue with a T-SQL statement from a C# application on 1 machine. The more times the query executes the longer the time it takes to return. On my test machine the query takes less than 2 seconds (and can finish the batch in about 6 hours), but on the box in question the query takes longer and longer with every pass (currently up to 3mins 30 sec, average 105 sec per record, guestimated query time 27 days and rising).
The SQL is as follows
[Table_Header].[HeaderID] is a big int primarykey
There are currently 32000 [Table_Header].[HeaderID]'s in the batch
[New_Table_Data] has no constraints
Each [Table_Header] will have up to 210 associated records in [Table_Data]
Currently [Table_Data] has around 8 million rows
The server is MS SQL 2008 R2, the C# application is running on the same machine as the server is installed
Any thoughts grately appreciated.
If somethings hard to do, its not worth doing - Homer Simpson
Jack of all trades, king of none!
I am having an issue with a T-SQL statement from a C# application on 1 machine. The more times the query executes the longer the time it takes to return. On my test machine the query takes less than 2 seconds (and can finish the batch in about 6 hours), but on the box in question the query takes longer and longer with every pass (currently up to 3mins 30 sec, average 105 sec per record, guestimated query time 27 days and rising).
The SQL is as follows
Code:
Pseudo
select [HeaderID] from [Table_Header] Where [myDate] < Some_Date
with each row in returned dataset
BEGIN TRANSACTION
INSERT [New_Table_Data]
SELECT * FROM [Table_Data] WHERE [HeaderID] = row.[HeaderID];
IF @@ERROR !=0 BEGIN ROLLBACK TRANSACTION RETURN END
DELETE FROM [Table_Data] WHERE [HeaderID] = row.[HeaderID];
IF @@ERROR !=0 BEGIN ROLLBACK TRANSACTION RETURN END
COMMIT TRANSACTION
mySQLCommand.CommanadText = <above SQL>
IAsyncResult res = mySQLCommand.BeginExecuteNonQuery()
wait until res.IsComplete
mySQLCommand.EndExecuteNonQuery(res)
wend
[Table_Header].[HeaderID] is a big int primarykey
There are currently 32000 [Table_Header].[HeaderID]'s in the batch
[New_Table_Data] has no constraints
Each [Table_Header] will have up to 210 associated records in [Table_Data]
Currently [Table_Data] has around 8 million rows
The server is MS SQL 2008 R2, the C# application is running on the same machine as the server is installed
Any thoughts grately appreciated.
If somethings hard to do, its not worth doing - Homer Simpson
Jack of all trades, king of none!