I am generating insert queries and then executing them.
On this insert query it is taking 1 second to query 100 records but almost 30 seconds to insert 100 records.
a different generated query which is basically the same inset query inserting into the same table but getting the data from a different view is fine, 4200 records inserted in 1 second.
The data being queried is not being affected by the insert query.
I am grasping at straws to identify the problem. I have tried to drop the constraits, run traces, looked at execution plans. I am out of ideas!!!
I know I have raised a thread before to do with the same problem about a week ago but this time I have identified that the updates are taking place, just very slowley.
Please help me solve this whilst I still have hair!
This is the query that is causing the problems. Insert query works fine if I comment out the "-- DuplicateAssetNo is null and " on the where clause!!
insert into tblAssetDataSourceIdentifier(
ADSI_A_Id, ADSI_AssetIdentifier, ADSI_Datasource, ADSI_ValidateDT)
select top 100 A_Id, AIR2_Id, 'AIR', 'Feb 4 2005 1:01PM'
from tblAsset
left join tblAssetDataSourceIdentifier on ADSI_A_Id = A_Id
inner join AIR.dbo.vZZPrinters on A_AssetNo = AssetNo
left join (
select dbo.fUnknown(AssetNo) as DuplicateAssetNo,
count(dbo.fUnknown(AssetNo)) as DuplicateAssetNoCount
from AIR.dbo.vZZPrinters
where dbo.fUnknown(AssetNo) <> 'Unknown'
group by dbo.fUnknown(AssetNo)
having count(dbo.fUnknown(AssetNo)) > 1) as DuplicateAssetNo
on AssetNo = DuplicateAssetNo
left join (
select dbo.fUnknown(SerialNo) as DuplicateSerialNo,
count(dbo.fUnknown(SerialNo)) as DuplicateSerialNoCount
from AIR.dbo.vZZPrinters
where dbo.fUnknown(SerialNo) <> 'Unknown'
group by dbo.fUnknown(SerialNo)
having count(dbo.fUnknown(SerialNo)) > 1) as DuplicateSerialNo
on DuplicateSerialNo = SerialNo
where
DuplicateAssetNo is null and
DuplicateSerialNo is null and
ADSI_Id is null and dbo.fUnknown(AssetNo) <> 'Unknown'
On this insert query it is taking 1 second to query 100 records but almost 30 seconds to insert 100 records.
a different generated query which is basically the same inset query inserting into the same table but getting the data from a different view is fine, 4200 records inserted in 1 second.
The data being queried is not being affected by the insert query.
I am grasping at straws to identify the problem. I have tried to drop the constraits, run traces, looked at execution plans. I am out of ideas!!!
I know I have raised a thread before to do with the same problem about a week ago but this time I have identified that the updates are taking place, just very slowley.
Please help me solve this whilst I still have hair!
This is the query that is causing the problems. Insert query works fine if I comment out the "-- DuplicateAssetNo is null and " on the where clause!!
insert into tblAssetDataSourceIdentifier(
ADSI_A_Id, ADSI_AssetIdentifier, ADSI_Datasource, ADSI_ValidateDT)
select top 100 A_Id, AIR2_Id, 'AIR', 'Feb 4 2005 1:01PM'
from tblAsset
left join tblAssetDataSourceIdentifier on ADSI_A_Id = A_Id
inner join AIR.dbo.vZZPrinters on A_AssetNo = AssetNo
left join (
select dbo.fUnknown(AssetNo) as DuplicateAssetNo,
count(dbo.fUnknown(AssetNo)) as DuplicateAssetNoCount
from AIR.dbo.vZZPrinters
where dbo.fUnknown(AssetNo) <> 'Unknown'
group by dbo.fUnknown(AssetNo)
having count(dbo.fUnknown(AssetNo)) > 1) as DuplicateAssetNo
on AssetNo = DuplicateAssetNo
left join (
select dbo.fUnknown(SerialNo) as DuplicateSerialNo,
count(dbo.fUnknown(SerialNo)) as DuplicateSerialNoCount
from AIR.dbo.vZZPrinters
where dbo.fUnknown(SerialNo) <> 'Unknown'
group by dbo.fUnknown(SerialNo)
having count(dbo.fUnknown(SerialNo)) > 1) as DuplicateSerialNo
on DuplicateSerialNo = SerialNo
where
DuplicateAssetNo is null and
DuplicateSerialNo is null and
ADSI_Id is null and dbo.fUnknown(AssetNo) <> 'Unknown'