I have three tables :
- ImportBatch
- PatientChartImages
- PatientChartBatchMapping (this table has foreign key to both ImportBatch and PatientChartImages)
I have an un-indexed view defined selecting records from 3 tables. I am explictly locking PatientChartImages table to generate blocking scenerios of production database by following command
begin transaction
update PatientChartImages set imagesequence=imagesequence
--Commit transaction
Above query locks PatientChartImages table. Also, following query times out :
select * from ImportBatch where importbatchid=@importbatchid
When i drop the view and follow the same process, ImportBatch query does not time out. Can anybody explain this behaviour. Is this by design or am i doing something crazy?
A view alone will not cause such behavior. But an indexed view definitely will. Or a foreign key constraint on imagesequence if one exists.