开发者

How do large blobs affect SQL delete performance, and how can I mitigate the impact?

I'm currently experiencing a strange issue that my understanding of SQL server doesn't quite mesh with. We use SQL as our file storage for our internal storage service, and our database has about half a million rows in it. Most of the files (86%) are 1mb or under, but even on fresh copies of our database where we simply populate the table with data for the purposes of a test, it appears that rows with large amounts of data stored in a BLOB frequently cause timeouts when our SQL server is under load. My understanding of how SQL server deletes rows is that it's a garbage collection process, i.e. the row is marked as a ghost and the row is later deleted by the ghost cleanup process after the changes are copied to the transaction log. This suggests to me that regardless of the size of the data in the blob, row deletion should be close to instantaneous. However when deleting these rows we are definitely experiencing large numbers of timeouts and astoundingly low performance.

In our test data set, it's files over 30mb that cause this issue. This is an edge case, we don't frequently encounter these, and even though we're looking into SQL filestream as a solution to some of our problems, we're trying to narrow down where these issu开发者_如何学Goes are originating from.

We ARE performing our deletes inside of a transaction. We're also performing updates to metadata such as file size stats, but these exist in a separate table away from the file data itself. Hierarchy data is stored in the table that contains the file information.

Really, in the end it's not so much what we're doing around the deletes that matters, we just can't find any references to low delete performance on rows that contain a large amount of data in a BLOB. We are trying to determine if this is even an avenue worth exploring, or if it has to be one of our processes around the delete that's causing the issue. Are there any situations in which this could occur? Is it common for a database server to come to the point of complete timeouts when many of these deletes are occurring simultaneously? Is there a way to combat this issue if it exists?


You are describing a performance issue, and as with any performance issue you need to approach it by first measuring. Guessing will get you nowhere fast. So use an appropriate investigation methodology, and Waits and Queues, yet again, applies perfectly. Observe, collect data, and analyze. You will certainly discover what is causing the queries to time out (is it blocking? is it IO? is it CPU?), and based on the actual finds we can recommend a proper fix.

As to answer you immediate question: no, deleting BLOBs will not cause any of the symptoms you describe. Those are typical contention symptoms.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜