NOLOCK HINTS IN REPORT Stored Procedures

烈酒焚心 提交于 2020-01-06 20:35:53

问题


We have some SSRS reports which run slowly with large amounts of data.

We thought to do some query optimization in backend stored procedures in the reports.

My question is, is it good to add with (nolock) hints in stored procedures (only in select statements) for reporting purposes?


回答1:


DB Locks of course are important to ensure you aren't getting 'dirty' data involved in your transactions. Still, there are conditions where you can safely use NOLOCK. For instance, if you must use a cursor ( best avoided, but sometimes necessary ), the cursor can be written to it picks up just the minimal key fields, under NOLOCK conditions, then inside the loop you read the tables as needed ( with locks ) using the cursor field values, carry out your changes, commit, and move to the next cursor rec to get you next set of keys ( under nolock ). It's asset if used wisely.



来源:https://stackoverflow.com/questions/31980354/nolock-hints-in-report-stored-procedures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!