Disadvantages:
1. Dirty reads are generated.
2. Applicable only to select query statements
Advantages:
1. In some documents, the SQL query efficiency with (nolock) can be increased by 33%.
2. Can Be Used in inner join statements
Dirty read: A User modifies a resource. At this time, another user just reads the modified record. Then, the first user gives up the modification and the data is returned before the modification, the two different results are dirty reads.
Details:
To improve the query efficiency of SQL statements, we generally consider creating an index first. In fact, apart from index creation, when we run the SQL command, we add a section with (nolock) in the syntax) this improves the query performance by locking a dataset in a large online query environment.
Note that with (nolock) SQL select may cause dirty read (dirty read ).
For example:
Select Count (Userid)
From Employee With (Nolock)
Join Working_group With (Nolock)
On Employee. userid = Working_group.userid
In addition to simple select statements, the Select syntax with join statements can also be used. But the delete, insert, and update commands that require transaction will not work...
In some documents, the SQL query efficiency with (nolock) can be increased by 33%.
The with (nolock) Command tells SQL server that our SELECT command does not need to consider the current table's transaction lock status, so the efficiency will be significantly improved, in addition, the lock phenomenon of the database system will be significantly reduced (including dead lock ).
Yes
Note that with (nolock) does not consider the current table transaction.
Lock, so when some data is in multiple phase transactions (for example, transaction transactions across multiple tables --> such as a withdrawal system),
(Nolock) will ignore the data currently processing the transaction process...
In other words, when nolock is used, it allows users to read data that has been modified but has not been completed yet. Therefore, if you need to consider the real-time integrity of transaction data, use with (nolock) should be considered.
If you do not need to consider transaction, with (nolock) may be a useful reference.
NOTE 1: With (<table_hint>)
Specify the table scan, one or more indexes used by the query optimizer,
Or the query optimizer uses this data table and uses the lock mode for this statement.
NOTE 2: With (nolock) is equivalent to read uncommitted