Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cancer192
Starting Member
10 Posts |
Posted - 2009-06-04 : 05:56:52
|
Hi,Im importing text file to database and updating the DuplicateInd after each import. Each file contains around 20k records.I'm getting the following error message during update:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.The code im using to update the DuplicateInd field:UPDATE aset a.DuplicateInd = 0FROM TABLE_1 AS a INNER JOIN(SELECT Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12 FROM TABLE_1 GROUP BY Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12 HAVING (COUNT(*) = 1)) AS b ON a.Field1 = b.Field1 AND a.Field2 = b.Field2 AND a.Field3 = b.Field3 AND a.Field4 = b.Field4 AND a.Field5 = b.Field5 AND a.Field6 = b.Field6 AND a.Field7 = b.Field7 AND a.Field8 = b.Field8 AND a.Field9 = b.Field9 AND a.Field10 = b.Field10 AND a.Field11 = b.Field11 AND a.Field12 = b.Field12UPDATE aset a.DuplicateInd = 1FROM TABLE_1 AS a INNER JOIN(SELECT Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12 FROM TABLE_1 GROUP BY Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12 HAVING (COUNT(*) > 1)) AS b ON a.Field1 = b.Field1 AND a.Field2 = b.Field2 AND a.Field3 = b.Field3 AND a.Field4 = b.Field4 AND a.Field5 = b.Field5 AND a.Field6 = b.Field6 AND a.Field7 = b.Field7 AND a.Field8 = b.Field8 AND a.Field9 = b.Field9 AND a.Field10 = b.Field10 AND a.Field11 = b.Field11 AND a.Field12 = b.Field12 For the first 50+/- files Ive imported, everything is ok. After that then im starting to get the timeout message. What is wrong?Thanks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-04 : 06:14:36
|
All your JOINs and ONs...Try this insteadUPDATE fSET f.DuplicateInd = SIGN(cnt - 1)FROM ( SELECT DuplicateInd, COUNT(*) OVER (PARTITION BY Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12) AS cnt FROM TABLE_1 ) AS f E 12°55'05.63"N 56°04'39.26" |
 |
|
|
cancer192
Starting Member
10 Posts |
Posted - 2009-06-04 : 13:13:50
|
Hi Peso,Im still getting the same timeout err..Thanks.quote: Originally posted by Peso All your JOINs and ONs...Try this insteadUPDATE fSET f.DuplicateInd = SIGN(cnt - 1)FROM ( SELECT DuplicateInd, COUNT(*) OVER (PARTITION BY Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12) AS cnt FROM TABLE_1 ) AS f E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-04 : 13:37:45
|
WHERE do you get the timeout? In your application?If so, increase the CommandTimeout value to a number larger than the default 30 seconds. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
cancer192
Starting Member
10 Posts |
Posted - 2009-06-04 : 21:39:24
|
| Yes in my application.Ive been reading about CommandTimeout. Will it be dangerous if I simply set it to 0?I have 10+ windows services running and all of them will doing the same kind of work (but on different tables) ie. import to db > update DuplicateInd > export to file if there's duplicate. Will there be a trap somewhere?Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-05 : 00:58:41
|
If you run your old "two update approach" in a query window for Management Studio, how long do they take?Then run my "one update approach" in another query window for Management Studio, how long does that query take?After this, please post back the results here. And you also will have an idea of what timing to set CommandTimeout for. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
cancer192
Starting Member
10 Posts |
Posted - 2009-06-05 : 10:15:33
|
| Ok, here's the stats:"two update approach" Query Profile Statistics Number of INSERT, DELETE and UPDATE statements: 2 Rows affected by INSERT, DELETE, or UPDATE statements: 2802744 Number of SELECT statements: 0 Rows returned by SELECT statements: 0 Number of transactions: 2 Network Statistics Number of server roundtrips: 1 TDS packets sent from client: 1 TDS packets received from server: 1 Bytes sent from client: 3710 Bytes received from server: 34 Time Statistics Client processing time: 0 Total execution time 102859: Wait time on server replies: 102859 "one update approach"Query Profile Statistics Number of INSERT, DELETE and UPDATE statements: 1 Rows affected by INSERT, DELETE, or UPDATE statements: 2802744 Number of SELECT statements: 0 Rows returned by SELECT statements: 0 Number of transactions: 1 Network Statistics Number of server roundtrips: 2 TDS packets sent from client: 2 TDS packets received from server: 2 Bytes sent from client: 690 Bytes received from server: 232 Time Statistics Client processing time: 16 Total execution time: 83031 Wait time on server replies: 83015 Thanks. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-06 : 13:20:12
|
Ok, your CommandTimeOut seems to need to be at least 90 seconds instead of the default 30 seconds. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|
|
|