2011年6月15日 星期三

[SQL] WITH(NOLOCK)

Using WITH(NOLOCK) can improve performance, at the cost of reliability and integrity.

Example: Consider a game database having many player information. We want to calculate proportion of female players. The database will vary every second. We don't need precise calculation.

We may use the following query:
SELECT COUNT(1) FROM player_information WITH(NOLOCK) WHERE gender IN ('female')
We can use WITH(NOLOCK) gracefully.

沒有留言:

張貼留言