Hot answers tagged

4

I agree with Erik that you should check your indexes. However, I would also try this statement, which will result in one less trip to the table. BEGIN TRANSACTION; UPDATE AggregationMeasurement WITH (UPDLOCK, SERIALIZABLE) SET ValueFloat = @ValueFloat WHERE Date = @Date AND AggregationConfigurationId = @AggregationConfigurationId; IF @@ROWCOUNT = 0 ...


3

these tables have foreign keys on a highly referenced table and lock is required by drop If FK constraints point to a table to be deleted, add CASCADE to also drop any such FK constraint (not the referencing tables). The manual: (CASCADE will remove a dependent view entirely, but in the foreign-key case it will only remove the foreign-key constraint, not ...


3

To prevent deadlocks, you are going to want the right index on this table. I suggest one of the following clustered indexes, if you can make it unique, even better. (Date, AggregationConfigurationId) -- alternatively (AggregationConfigurationId, Date) The reason you need indexing is two-fold: otherwise the INSERT and NOT EXISTS will lock far too much, and ...


Only top voted, non community-wiki answers of a minimum length are eligible