开发者

Do SQL constraints cause slowness?

I have a few constraints (to default the value of the 开发者_高级运维column) on a table that is being updated. The update is really slow, and I was wondering if it could be the constraints fault?

The constraint in question is:

ALTER TABLE [dbo].[OrderCustomers] ADD  CONSTRAINT [DF_OrderCustomers_AmountTotal]  DEFAULT ((0.00)) FOR [AmountTotal]

The update statement is just changing a few columns one of which is the column in the Constraint above and the a few other columns that don't have FKs on them.

FYI: I disabled all triggers to isolate the problem.


It's highly unlikely a default constraint on a column is going to even be noticeable. There are so many things that could cause a slow update. However, the first place I would look is any triggers on the table being updated. This could cause a whole slew of performance issues.

One of the best ways to diagnose this is to fire up SQL Profiler and see what's happening on your SQL Server when you do an update. You might be quite surprised at what's happening.


Unless you've coded them really badly then no.

By badly, I mean a things like a UDF to access a table to generate a value. Or sending an email RBAR in a trigger.

A slow write can be caused by many things. I doubt constraints. See Why does an UPDATE take much longer than a SELECT?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜