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 |
|
DharmeshParekh
Starting Member
1 Post |
Posted - 2009-06-19 : 09:21:51
|
| insert into tran_table(location,cartype,specificdate,capacity,Nocollection,minLor,NoDropoff,Nobooking) select lc.location,'ecm',tmpDt.value,0,1,sippcode.lorvalue,0,0 from @Locations lcinner join @tmpSippCode SippCode on SippCode.SippCodeId = lc.sippcodeIDcross join @tmpDateRange tmpDtwhere not exists (select 1 from tran_table where location =lc.location and specificdate = tmpDt.value)can you tell me what is wrong with above query. sometimes it takes too much time to complete the execution. so i got timeout error in front-end application. is it the cross-join culprit? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-06-19 : 09:41:20
|
| Very likely. Whenever select 1 from tran_table where location =lc.location and specificdate = tmpDt.value doesn't exist, you're going to get every row out of it for each row in @Locations lcinner join @tmpSippCode SippCode on SippCode.SippCodeId = lc.sippcodeIDthat's called a Cartesian product. Are you sure that's what you want?Explain what you are trying to accomplish with the query and maybe we can re-write it.JimJim |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|